I’m new to Stack and this is my first question, but I did search and wasn’t able to find anything that was specifically what I am trying to accomplish. I’m all for learning, so any reference material that would help me better understand how to approach this would be appreciated, but if someone wants to provide some example code I
How do I measure the execution time of JavaScript code with callbacks?
I have a piece of JavaScript code that I am executing using the node.js interpreter. How can I measure the time taken by these database insert operations? I could compute the difference of date values after and before this piece of code but that would be incorrect because of the asynchronous nature of the code. Answer Use the Node.js console.time()
How to access the parentNode of a selection to raise an element?
I’ve created the following document: When I mouse over each path I want to append it last inside the svg:g so it appears on top of the other lines, but I don’t know how to properly select the parentNode: p1 works, but I wanted to make sure that this is a .line, so I preferred to use current_gene_pcp, but p2
How to add listener for a custom event in the DOM?
What I want is to create my own function that will be bound as an event listener similar to how other event listeners (e.g., onclick) are set: Is it possible and if so how? Answer The problem you have is the browser does not realize it is a function in there. It is a string, the only way you can
How do I get the current time only in JavaScript
How can I get the current time in JavaScript and use it in a timepicker? I tried var x = Date() and got: Tue May 15 2012 05:45:40 GMT-0500 But I need only current time, for example, 05:45 How can I assign this to a variable? Answer or
Is there any way to create mongodb like _id strings without mongodb?
I really like the format of the _ids generated by mongodb. Mostly because I can pull data like the date out of them client side. I’m planning to use another database but still want that type of _id for my document. How can I create these ids without using mongodb? Thanks! Answer Object IDs are usually generated by the client,
How to define setter/getter on prototype
EDIT Oct 2016: Please note this question was asked in 2012. Every month or so someone adds a new answer or comment that refutes an answer, but doesn’t really make sense to do so as the question is probably out of date (remember, it was for Gnome Javascript to write gnome-shell extensions, not browser stuff, which is quite specific). Following
how to get youtube video id from url
I am trying to check whether a url is a valid youtube video URL and get the youtube video ID from it, so far I am using a simple javascript split function in order to achieve this, however this has some minor disadvantages as youtube has multiple URL’s. I have been viewing other stackoverflow threads however all of them only
Sending websocket ping/pong frame from browser
I keep reading about ping/pong messages in websockets to keep the connection alive, but I’m not sure what they are. Is it a distinct frame type? (I don’t see any methods on a javascript WebSocket object in chrome related to ping-pong). Or is it just a design pattern (e.g. I literally send “ping” or any other string to the server
setInterval(function(),time) change time on runtime
I want to change setInterval function time when my code is running. I try this First SetInterval does not work! Answer You’re clearing the interval on the next line, so the first one wont work, as it gets cleared right away : Also, as gdoron says, setting a interval of nothing isn’t really valid, and not a really good idea