js获取键值对

获取键值对

一.

var obj = {'id':1,'name':'王大锤'};
for(var key in obj){
    //key
    console.log(key)    
    //value
    console.log(obj[key])
}

二.

var obj = {'id':1,'name':'王大锤'};
console.log(Object.keys(obj));
JSRUN notes