JS 对象API之获取原型对象

1、从 构造函数 获得 原型对象:

构造函数.prototype

2、 对象实例 获得 父级原型对象

方法一: 对象实例.__proto__        【 有兼容性问题,不建议使用】

方法二:Object.getPrototypeOf( 对象实例 )

代码栗子:

function Student(){
    this.name = "小马扎"; 
    this.age = 18;
}
var lilei = new Student();  // 创建对象实例
console.log(Student.prototype);  //Student{}
console.log(lilei.__proto__);  //Student{}
console.log(Object.getPrototypeOf(lilei));    //Student{}
原文地址:https://www.cnblogs.com/minigrasshopper/p/8066735.html