We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
摘抄自《http://www.0313.name/2017/01/23/prototype2.html》
圆形代表对象的名字 方形代表属性名 实线代表对象的分界 虚线代表引用 菱形代表基本值
1、原型链是单链,只往一个方向流向,没有回路 2、只有Function的__proto__指向自己的prototype,这也向我们解释了为什么Function.prototype类型是function 3、我们通过__proto__只能获取到原型对象中的方法和属性,所以persion1通过原型链是获取不到Persion的myName属性,但是我们可以通过原型对象的constructor来获取或者修改Persion的属性(这点太给力了) 请注意,有时候这个方法也不好使,因为原型对象的constructor是可以改变的,不一定指向原型对象所在的函数对象 4、普通对象的_proto__一定指向创造它的函数对象的prototype 5、原型对象的__proto__一定指向Object.prototype! 6、通过图我们可以简单理解,拥有原型对象属性的对象是函数对象,否则为普通对象 7、原型链是有开始和尽头的,开始于null,结束于普通对象 8、所有的函数对象都是Function以new的方式创造出来了,包括Function自己且每个函数对象的__proto__都指向了Function.prototype 9、Object是所有对象的父类,我们也可以称之为基类,不过不要纠结于叫什么,因为我们通过图可以看到每一个对象(不管是原型对象还是普通对象还是函数对象)的通过原型链都可以引向Object.prototype
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原型链图
The text was updated successfully, but these errors were encountered: