Chrome會對key為數字的陣列自動排序
Chrome browsers process numerically named keys first and in numeric sequence not insertion sequence.
1
2
3
4
5
6
7
8
9
| var obj = {3: 'a' , 2: 'b' , 'foo' : 'c' , 1: 'd' }, result = []; for ( var prop in obj) { result.push(prop); } result.toString(); //Chrome -> "1,2,3,foo" //Other browsers -> "3,2,foo,1" |