I have a question about for loop
in js, here are examples:
In this part, child
is object
(what I want).
for (var i = 0; i < element.childNodes.length; i++) {
var child = element.childNodes[i];
console.log(typeof(child));
}
But when change the code, child
become to String
, valued 0, 1, 2 ...
for (var child in element.childNodes) {
console.log(typeof(child));
}
Why the two types of for loop
got different results?
Thanks..