JS中Object的一些关于原型的方法

1、Object.getPrototypeOf(obj)

该方法返回 obj 对象的原型对象,等同于 obj.__proto__

function Person(){
  this.name = 'jack'
}
let man = new Person();
console.log(Object.getPrototypeOf(man) === Person.prototype);   //true
console.log(Object.getPrototypeOf(man) === man.__proto__);    //true

猜你喜欢

转载自www.cnblogs.com/wenxuehai/p/10337389.html
今日推荐