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

> 我用原生的bind试了obj.**proto**.friend = "Kitty"; // 修改原型 #49

Open
lonkang opened this issue Jun 3, 2020 · 1 comment

Comments

@lonkang
Copy link

lonkang commented Jun 3, 2020

我用原生的bind试了obj.proto.friend = "Kitty"; // 修改原型
bar.prototype.friend; // 返回错误,这里被修改了// Kitty
发现也是会修改的,这个我有点蒙了哈
{friend: "Kitty", constructor: ƒ}
paste.html:68 {friend: "Kitty", constructor: ƒ},打印出来是一样的东西

var Foot = bar.bind(foo, "Jack")
var a = new Foot(20);
a.proto.friend = "Kitty"; // 修改原型
console.log(bar.prototype.friend)
console.log(bar.prototype)
console.log(a.proto)

我也试了一下,不懂为啥会说是返回错误,原生的bind 也修改了原型,那这里出错的原因,作者也没有解释

Originally posted by @Pomelo1213 in #23 (comment)

@lonkang
Copy link
Author

lonkang commented Jun 3, 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