JS——Object.create()

将一个对象绑定到实例化对象的原型

let person = {
  isHuman: false,
  printIntroduction: function () {
    console.log(this.isHuman);
  }
};

let me = Object.create(person);
me.name = "Matthew"; 
me.isHuman = true; 
me.printIntroduction();  // true
console.log(me.__proto__.isHuman);  //false

console.log(me);

image.png

你可能感兴趣的:(JS——Object.create())