object.create(proto, propertiesObject)
当proto
为null
时,创建一个空对象,没有原型
const person = Object.create(null)
console.log(person);
创建一个新的对象,他的原型指向接收的参数对象。
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()
创建一个新的对象,他的原型指向Object.prototype
const person = new Object()
console.log(person);