1. 程式人生 > >js for in循環遍歷對象,獲取key:value值

js for in循環遍歷對象,獲取key:value值

ole con info 循環 對象 test bsp 技術 inf

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

技術分享圖片

js for in循環遍歷對象,獲取key:value值