V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
clippit
V2EX  ›  问与答

为什么 Function.prototype.bind 以后,不能再换一个 this 了?

  •  1
     
  •   clippit · 2014-07-11 11:01:51 +08:00 · 2575 次点击
    这是一个创建于 3579 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如 foo.bind(A).bind(B).call(C),最后的 this 其实还是 A。我试了一下在 Chrome 里是这样的逻辑,难道 ECMAScript 里面就是规定这样的?感觉有点奇怪啊
    4 条回复    2014-07-11 13:08:45 +08:00
    coolicer
        1
    coolicer  
       2014-07-11 11:18:08 +08:00
    没有见过链式用法
    adjusted
        2
    adjusted  
       2014-07-11 11:54:21 +08:00
    规定里面是bind之后this就不能覆盖了
    livelazily
        3
    livelazily  
       2014-07-11 11:58:09 +08:00   ❤️ 1
    lijsh
        4
    lijsh  
       2014-07-11 13:08:45 +08:00
    不能,想绑定新的上下文请在原函数foo中操作。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1106 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:45 · PVG 06:45 · LAX 15:45 · JFK 18:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.