object.create(proto, propertiesObject)
當(dāng)proto
為null
時(shí)双抽,創(chuàng)建一個(gè)空對(duì)象撞蜂,沒(méi)有原型
const person = Object.create(null)
console.log(person);
創(chuàng)建一個(gè)新的對(duì)象赦拘,他的原型指向接收的參數(shù)對(duì)象贫奠。
const human = {
name: "danae",
isHuman: true,
printIntroduction: function () {
console.log(`My name is ${this.name}. Am I human? ${this.isHuman}`);
}
};
var person = Object.create(human)
console.log(person);
new Object()
創(chuàng)建一個(gè)新的對(duì)象笤闯,他的原型指向Object.prototype
const person = new Object()
console.log(person);