首页 > 其他 > 详细

第6章 面向对象的程序设计(待完善)

时间:2015-11-27 16:42:43      阅读:205      评论:0      收藏:0      [点我收藏+]

 

属性类型:

    数据属性--4大行为:[[Configurable]]

              [[Enumerable]]

              [[Writable]]

              [[Value]]

         修改方法 obj.defineProperty(obj,"name",{

              Configurable:false,

              ....

             })

    访问器属性--4大特性:[[Configurable]]

               [[Enumerable]]

               [[Get]]

               [[Set]]

          

          定义方法 obj.defineProperty(obj,"name",{

              Configurable:false,

              ....

             })

定义多个属性:

object.defineProperties(book,{

  _year:{

    value:2004

  },

  

  _edition:{

    value:1

  },

  

  year:{

    get:function(){

      return this._year;

    },

    set:function(newValue){

      if(newValue>2004){

        this._year = newValue;

        this._edition =+ newValue - 2004;

      }

    }

  },

})

 

读取属性的特性

  Object.getOwnPropertyDescriptor()

第6章 面向对象的程序设计(待完善)

原文:http://www.cnblogs.com/alex-web/p/5000583.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!