您好!欢迎来到聚码网

聚码网

热门搜索: 相亲小程序    搭子源码    直播系统自有商城   
  • 对象数据和访问器可配置和可枚举特性默认的不是true吗?
  • 聚码交流
  • 0 0
  • yhuxAvNbtxUM
    0000-00-00 00:00:00
  • 回帖
varbook={};Object.defineProperties(book,{_year:{value:2004},edition:{value:1},year:{get:function(){returnthis._year;},set:function(newValue){if(newValue>2004){this._year=newValue;this.edition+=newValue-2004;}}}});vardescriptor=Object.getOwnPropertyDescriptor(book,"_year");alert(descriptor.value);//2004alert(descriptor.configurable);//falsealert(typeofdescriptor.get);//"undefined"vardescriptor=Object.getOwnPropertyDescriptor(book,"year");alert(descriptor.value);//undefinedalert(descriptor.enumerable);//falsealert(typeofdescriptor.get);//"function"以下这两行看不懂alert(descriptor.configurable);//falsealert(descriptor.enumerable);//false对象默认的可配置属性和可枚举属性是true吧示例代码未设置这两个属性,默认的应该为true吧PS:红宝书6.1.3(24印143页)
最近热帖
近期热议
联系我们
Q Q:317563994
电话:400-000-000
邮箱:317563994@qq.com
时间:09:00 - 17:00