分享一个Object.defineProperties 定义一个在原对象可读可写的方法

时间:2022-07-07 08:22:43
function A(){
   this.name = 'hellow word';
}

Object.defineProperties(
  A.prototype,{
  doSomething2 : {
    value: function(parm){
      console.log(parm)
    },
    enumerable: true,
    configurable: true,
    writable: true
  }
})

var a2 = new A()

a2.doSomething2();
  

相关文章