javascript对象按键的升序顺序排序吗?Javascript对象按键排序本身
我第一次注意到它。
/* It does maintain a order. The order in which you inserts the value. And if it does not maintain any orders, please show me example, that will be really helpful to understand me the concepts.
Thanks in advance.
*/
var a = {"13" : "1", "15" : "2", "14" : "3", "12" : "4"};
console.log(JSON.stringify(a)); /* This is nothing to do with for loop */
for(let i in a) {
\t console.log(i + " = " + a[i]);
}
/* But the keys other than numbers are not sorting. */
var b = {"c" : "1", "a" : "2", "b" : "3", "d" : "4"};
for(let i in b) {
\t console.log(i + " = " + b[i]);
}
第一个目的通过本身排序。我正在为这两个对象创建键作为字符串。但第二个对象不是排序。