获取实例对象的原型对象

index.js

const instance = {};

console.log(instance.__proto__ === Object.prototype); // true, 浏览器才需要部署
console.log(instance.constructor.prototype === Object.prototype); // true, 改变 prototype 时没有同步修改 constructor 时会异常
console.log(Object.getPrototypeOf(instance) === Object.prototype); // true, 靠谱

posted on 2021-09-10 09:54  aisowe  阅读(96)  评论(0编辑  收藏  举报

导航