Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

原型及原型链的理解 #14

Open
MaMaFish opened this issue Mar 9, 2020 · 0 comments
Open

原型及原型链的理解 #14

MaMaFish opened this issue Mar 9, 2020 · 0 comments

Comments

@MaMaFish
Copy link
Owner

MaMaFish commented Mar 9, 2020

构造函数的prototype属性指向的对象就是原型对象。每个实例对象的__proto__属性也指向该对象的原型(父对象)。
原型对象中可以设置用该构造函数创建的实例对象共同拥有的属性和方法。

Object.__proto__ === Function.prototype;
Function.prototype.__proto__ === Object.prototype;
Object.prototype.__proto__ === null;

原型链:访问实例化对象的属性时会触发get方法,它会先在自身属性上查找,如果没有这个属性,就会去__proto__指向的父对象中查找,一层层向上直到查找到顶层对象Object,这个查找的过程就是原型链

@MaMaFish MaMaFish changed the title 原型及原型链的理解 第14题:原型及原型链的理解 Mar 9, 2020
@MaMaFish MaMaFish changed the title 第14题:原型及原型链的理解 原型及原型链的理解 Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant