clippit
V2EX  ›  问与答

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

  •  1
     
  •   clippit · Jul 11, 2014 · 3105 views
    This topic created in 4324 days ago, the information mentioned may be changed or developed.
    比如 foo.bind(A).bind(B).call(C),最后的 this 其实还是 A。我试了一下在 Chrome 里是这样的逻辑,难道 ECMAScript 里面就是规定这样的?感觉有点奇怪啊
    4 replies    2014-07-11 13:08:45 +08:00
    coolicer
        1
    coolicer  
       Jul 11, 2014
    没有见过链式用法
    adjusted
        2
    adjusted  
       Jul 11, 2014
    规定里面是bind之后this就不能覆盖了
    livelazily
        3
    livelazily  
       Jul 11, 2014   ❤️ 1
    lijsh
        4
    lijsh  
       Jul 11, 2014
    不能,想绑定新的上下文请在原函数foo中操作。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3218 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 14:36 · PVG 22:36 · LAX 07:36 · JFK 10:36
    ♥ Do have faith in what you're doing.