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

 

属性类型:this

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

              [[Enumerable]]get

              [[Writable]]it

              [[Value]]io

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

              Configurable:false,function

              ....object

             })方法

    访问器属性--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()

相关文章
相关标签/搜索