Anyone have had an issue before where running javacript Object.keys or Object.values returns a sequence number as string instead of the actual key or value? In otherwords, if I have three properties in my object and I run e.g:
for(var value in Object.values(myObject)){
console.log(value);
}
It prints out:
0
1
2
Any ideas why this might be happening? It is a JSON object, so the value is not just string, but nested, if that makes any difference.
myObjectin the question.for ... inloop loops through the keys of an object, andObject.values()returns an array.Object.values(myObject)returns an array, andvalueis the index in afor .. in. usefor ... ofto get the value instead.for ... ofloop to log out the actual values of your object.