Consider:
var object = {
foo: {},
bar: {},
baz: {}
}
How would I do this:
var first = object[0];
console.log(first);
Obviously, that doesn’t work because the first index is named foo
,
not 0
.
console.log(object['foo']);
works, but I don’t know it’s named foo. It could be named anything. I just want the first.
for first key of object you can use
for value
You could do something like this: