Convert NodeList to Array
Now that most browsers have implemented querySelectorAll, the native selectorEngine, many framework-dependent developers are getting a rude awakening when dealing with the result of QSA calls: the NodeList object. NodeLists are array-like but don't feature many of the methods provided by the Array, like
var nodesArray = Array.prototype.slice.call(document.querySelectorAll("div"));
The result of the code above is a true Array object containing all of the nodes returned by the QSA. You could even make the code shorter with this alternative:
var nodesArray = .slice.call(document.querySelectorAll("div"));
Both snippets will give you an Array for which you can iterate over and do all those other awesome array things!
One of the worst kept secrets about AJAX on the web is that the underlying API for it,
XMLHttpRequest, wasn't really made for what we've been using it for. We've done well to create elegant APIs around XHR but we know we can do better. Our effort to...
Whenever I go to Google Analytics I notice a slight flicker in the dropdown list area. I see a button appear for the shortest amount of time and the poof! Gone. What that tells me is that Google is making their site function...
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?