Lots of JavaScript libraries (jQuery, Zepto) seem to be calling Array.prototype.slice.call on querySelectorAll(), getElementsByTag or ClassName results...
From reading many many similar questions/answers on StackOverflow I do understand that its to convert a NodeList result to a real Array so that you can invoke Array methods (slice, pop) on the results which are not available on NodeLists - but what I don't understand is why? You don't usually really need slice/pop on a list of DOM nodes + NodeLists already have a length property so they're traversable anyway.
Some answers seem to imply that its because a NodeList is pointing to live DOM objects. But again if you convert it to an Array, the references are still pointing to live DOM nodes - so whats the difference?
Or is it something else that I'm completely missing? Does it help Zepto/jQuery to somehow cache multiple property calls for DOM elements? (although I don't really see how since those are still live DOM references)
NodeList
is pointing to live DOM objects, but that means that when one is destroyed (or is no longer a valid item for the list), it and its spot is removed from the list. When you slice into an array, it's not the same "live" list - the elements themselves are live, but not the list itself. When an item is destroyed, its place is still kept in the array...but it won't represent the element - I'm guessing it becomes undefined or null.