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{}
