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

原型链 #11

Open
Genluo opened this issue Aug 31, 2019 · 0 comments
Open

原型链 #11

Genluo opened this issue Aug 31, 2019 · 0 comments

Comments

@Genluo
Copy link
Owner

Genluo commented Aug 31, 2019

这一块感觉一张图就可以,上面的学习中都有涉及,但是在ES6中类的继承也有特定的规则,需要把这一点搞清楚,可以查看上面对于ES6类原型链的介绍。

注意

  • 函数、数组、对象构造函数都存在__proto__
  • 注意搞清楚对象或者函数上方法的来源

例子

// 连等赋值问题
var a = {n: 1};
var b = a;
a.x = a = {n: 2};
alert(a.x); // --> undefined
alert(b.x); // --> {n: 2}
// https://segmentfault.com/a/1190000004224719

// 造成循环引用
var a = {};
a.a = a;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant