I'm training with using Javascript objects, and I found these examples of representing Javascript arrays:
var obj = {
key : {
0 : {name : "test0"},
1 : {name : "test1"},
2 : {name : "test2"}
}
}
var obj2 = {
key : [
{name : "test0"},
{name : "test1"},
{name : "test2"}
]
}
console.log(obj.key[0].name); //test0
console.log(obj2.key[0].name); //test0
Which of these is the appropriate representation of an array? Are these equivalent, and why?