js for in循环遍历对象,获取key:value值

 

var testObj = {
'a':'111',
'b':'222',
'c':'333',
'd':'444'
}
for(var i in testObj){
console.log(i); //a,b,c,d
}
for(var i in testObj){
console.log(testObj[i]); //111,222,333,444

 

posted @ 2019-03-07 10:09  Fourteen  阅读(19912)  评论(0编辑  收藏  举报