返回文章列表

JS查缺补漏1(原型)

先看示例

const person = {
	arms: 2,
	legs: 2
}

// 通过 Object.create 将 person 设为 father 的原型const father = Object.create(person)
console.log(father) //{}console.log(father.arms) //2console.log(father.proto === person) //true
// Object.create 第二个参数可以设定属性const son = Object.create(father, {	name: {		value: "xixi",		enumerable: true	}})