Object.setPrototypeOf(obj, proto):设置一个对象的原型对象,返回参数对象本身
let proto = {}
let obj = {
x: 10
}
Object.setPrototypeOf(obj, proto)
proto.y = 20
proto.z = 40
obj.x
obj.y
obj.z
Object.setPrototypeOf(1, {})
Object.setPrototypeOf('1', {})
Object.setPrototypeOf(true, {})
Object.setPrototypeOf(undefined, {})
Object.setPrototypeOf(null, {})
Object.getPrototypeOf(obj):获取对象的原型对象
Object.getPrototypeOf(obj)
Object.getPrototypeOf(obj) === proto
Object.getPrototypeOf(1)
Object.getPrototypeOf('1')
Object.getPrototypeOf(true)
Object.getPrototypeOf(1) === Number.prototype
Object.getPrototypeOf('1') === String.prototype
Object.getPrototypeOf(true) === Boolean.prototype
Object.getPrototypeOf(undefined)
Object.getPrototypeOf(null)
proto.isPrototypeOf(obj):判断一个对象是否在另一个对象的原型链上