This question already has an answer here:
- Is Chrome's JavaScript console lazy about evaluating arrays? 6 answers
I really don't understand what could be going on here. So I have a function which takes a 2d array and a string and iterates through the 2d array and checks if any subarrays contain the string. But somehow I can't iterate over this object/array and I'm really confused as to what it actually is. I've done lots of iteration in javascript. I've tried for-in, for-of (es6), C stlye(like below), forEach(callback), map... nothing works.
_makeOrUpdateCase = (arrayOfArrays, str) => {
console.log(arrayOfArrays); //returns the object/array shown in image below, expected
console.log(typeof(arrayOfArrays)); //object
console.log(Array.isArray(arrayOfArrays)); //true - huh? is this array or object??
for (var i = 0; i < arrayOfArrays.length; i++) {
console.log(arrayOfArrays[i]) //this does not work
console.log(i); //nothing is printed out, as if the loop is simply ignored
}
Here is the output I get.. you can see that the stuff I'm printing in the loop is not executed. I know javascript can be weird but c'mon what is going on here, I have no idea what to google. I've iterated over arrays and objects lots of times in this code.