I'm using Google Chrome's Console window to try and figure out why I'm not able to loop over an array in javascript.
I have a javascript object called moveResult
that looks like this:
I'm trying to loop over the MoveParts
in javascript like this:
for (var movePart in moveResult.MoveParts) {
console.log(movePart.From);
};
I always get undefined
instead of the actual value. However, If I try to access the first item explicitly I get what I want, like this:
console.log(moveResult.MoveParts[0].From);
The result of this is "b1"
.
Why isn't my loop working?
I've also tried a foreach:
moveResult.MoveParts.foreach(function (movePart) {
console.log(movePart.From);
};