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

属性类型:

    数据属性--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()

原文地址:https://www.cnblogs.com/alex-web/p/5000583.html