js Object.keys

墨阳羽
2023-12-01
/**
 * Created by W.J.Chang on 2014/5/23.
 */
d = 1;
var a = {a:'b',c:'d'};

// 枚举Keys
for(var i in a) {
    console.log(i);
}

console.log("----");

Object.prototype.d = 'e';

for(var i in a ){
    console.log(i);
}

console.log("----");

for(var i in a ){
   if(a.hasOwnProperty(i)) {
       console.log(i);
   }
}

console.log("----");

console.log(Object.keys(a));


 类似资料:

相关阅读

相关文章

相关问答