Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

遍历JavaScript json是按照顺序吗

$
0
0
var jsons = {}
for(var i = 0; i < 12; i++){
    var tt = {};
    tt.val = i;
    tt.key = "dsfs";

    jsons[ i ] = tt;
}

for(var k in jsons){
    console.log(jsons[ k ])
}

###遍历结果 应该是无序的啊 为什么


{ val: 0, key: 'dsfs' }
{ val: 1, key: 'dsfs' }
{ val: 2, key: 'dsfs' }
{ val: 3, key: 'dsfs' }
{ val: 4, key: 'dsfs' }
{ val: 5, key: 'dsfs' }
{ val: 6, key: 'dsfs' }
{ val: 7, key: 'dsfs' }
{ val: 8, key: 'dsfs' }
{ val: 9, key: 'dsfs' }
{ val: 10, key: 'dsfs' }
{ val: 11, key: 'dsfs' }

正常来说是没有顺序的,javascript遍历表是按照顺序遍历的????


Viewing all articles
Browse latest Browse all 14821

Trending Articles