标签:
遍历成员:
var mc = {}; Object.defineProperty(mc,"name",{value:"jlp",writable:false,enumerable:true}); mc.age = "16"; for(x in mc){ console.log(x); console.log(mc[x]); }
遍历属性:
var arr = []; // var = new Array();
arr = Object.keys(mc); // 遍历所有属性
判断属性是否在对象中:
boolean = "name" in mc //true or false
boolean = mc.hasOwnProperty("name");
判断类属性的 属性描述:
var mc = {name:"jlp",age:"16"}; if (Object.getOwnPropertyDescriptor(mc,"age").configurable) { delete mc.age; }
标签:
原文地址:http://www.cnblogs.com/Tachi/p/5734801.html