Prototype and prototype chain

(1) Prototype

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

__proto: implicit prototype

prototype: explicit prototype

(2) Prototype chain

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

Object is ultimately the big boss

instanceof: Climb up layer by layer to see if you can find it. If you can find it is true, if you can't it is false

Guess you like

Origin blog.csdn.net/Luckyzhoufangbing/article/details/108618152