Why do nodelists contain extra undefined items that are not reflected in its length property?
问题 Background: I came across a very strange phenomenon while working with a node list. I wanted to use getElementsByClassName or something similar and then sort it. I decided one way would be to iterate through the nodelist and push each item to an array and sort the array. (This did work by the way but not as expected). I tried using the for (var i in nodeList) to iterate through, but it kept throwing an exception on the last few items, which were undefined. the weird part is I could instead