我有看起来像这样的对象。Javascript - 对象,for循环从2开始
foo = {
0 : {
'bar' : 'baz',
'qux' : 'quux',
'this' : { 'hello' : 'yes' } // this is the object I want to extract
}
1 : {
'bar' : 'baz',
'qux' : 'quux',
'this' : { 'hello' : 'yes' } // extract
}
2 : {
'bar' : 'baz',
'qux' : 'quux',
'this' : { 'hello' : 'yes' }, // extract
'that' : { 'hello' : 'no' } // extract
}
}
用了这样的循环,我得到遍历每个对象:
for(var i in foo){
...
}
的问题是,我只是想拉从第三和更大的子对象中的数据比(”这')从每个对象。
对象属性没有排序。改用数组。 – VisioN 2013-04-04 09:12:54
对象是无序的。没有真正的“第一”或“第二”键值对的概念。你只是试图让所有发生的值都是对象的键? – Blender 2013-04-04 09:13:15
如果我总是知道他们会按这个顺序来? – Philip 2013-04-04 09:13:59