//添加数据属性 var obj={}; Object.defineProperty(obj,"newDataProperty",{ value:100, configurable:true, writable:true, enumberable:true }); obj.newDataProperty = 102; console.log(obj.newDataProperty); //列出对象属性对象 var names = Object.getOwnPropertyNames(obj); for(var i = 0; i < names.length; i++){ var prop = names[i]; document.write(prop +":"+ obj[prop]); }
添加回答
举报
0/150
提交
取消