There is a strange issue with the nested array in my current project that I need help with.
When I log the nested array in console.log as individual values, it displays correctly.
For example:
console.log("Array: " + arr) //Array: 0,0,0,0,0,0,0,1
However, when I log the array as an object, the output values are completely different. Upon expanding it on Chrome's developer tools, this is what I see:
console.log(arr)//(2)[Array(2), Array(2)]
0: [2][1,4]
1: [2][0,1]
Sometimes JavaScript/developer tools can be unpredictable, so I need guidance from the community.
I am confident there are no pointer issues because the two print statements happen immediately after each other and only involve simple operations like incrementing by +1 on the main nested array.
I searched online but found no similar cases to mine, hence why I'm reaching out here. This may be the best example I can provide, and anything else may not add much value to this discussion.
Another strange thing I noticed concerning the same matrix object is that when I try to access a specific element e.g. arr[0][0][0]
, the retrieved value is unexpected.
Thank you for your assistance, and if there are no known issues or considerations regarding either the developer tools or JavaScript, I will close this query.
Update: When expanded in the developer tools, this line:
https://i.sstatic.net/vp7cd.png
Returns a whole new set of values. The initial 14 somehow becomes 67 upon expansion. https://i.sstatic.net/LUO7G.png