プロトタイプとプロトタイプチェーン

(1)プロトタイプ

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

__proto:暗黙のプロトタイプ

プロトタイプ:明示的なプロトタイプ

(2)プロトタイプチェーン

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

オブジェクトは最終的には大ボスです

instanceof:レイヤーごとに登って、見つけられるかどうかを確認します。見つけられた場合はtrue、見つからない場合はfalse

おすすめ

転載: blog.csdn.net/Luckyzhoufangbing/article/details/108618152