方式一
var obj = {'0':'a','1':'b','2':'c'};
for(var i in obj) {
console.log(i,":",obj[i]);
}
方式二
var obj = {'0':'a','1':'b','2':'c'};
Object.keys(obj).forEach(key => {
console.log(key,obj[key]);
})
var obj = {'0':'a','1':'b','2':'c'};
for(var i in obj) {
console.log(i,":",obj[i]);
}
var obj = {'0':'a','1':'b','2':'c'};
Object.keys(obj).forEach(key => {
console.log(key,obj[key]);
})
本文标题:javascript遍历对象
本文链接:https://www.haomeiwen.com/subject/fhdqbqtx.html
网友评论