![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
对象、json
陈才人
兴趣
展开
-
javaScript 对象转字符串顺序改变
var obj = {"数量":"a","6":8,"剪刀":"c"}; var obj_Str=JSON.stringify(obj); //输出obj_Str结果,key为数字时提前 {"6":8,"数量":"a","剪刀":"c"} //用循环也一样 for(var i in obj) { console.log(obj[i]);//结果为8,a, c;也会改变 } ...原创 2021-07-25 18:47:08 · 323 阅读 · 0 评论 -
javaScript 用变量作为对象 key引用
var a ={"日期":1,"订单":2}; var d="日期"; document.write( a[d] );//输出结果:1 a[d]等价于a.日期 document.write( a.[d] );//输出结果:错误原创 2021-07-24 17:38:49 · 227 阅读 · 1 评论