原型 和 原型链

(一) 原型

function Person() {}
var person = new Person()
console.log(person.__proto__ === Person.prototype)//true
console.log(Person.prototype.constructor===Person)//true

__proto:隐式原型

prototype: 显式原型

(二)原型链

class Person {}
class Student extends Person {}
let xiaoming = new Student()

Object 最终 是 大 Boss

instanceof:一层一层往上爬,看看能不能找到,能找到就是 true,不能就是false

猜你喜欢

转载自blog.csdn.net/Luckyzhoufangbing/article/details/108618152