Can I get an unbound function from a bound function in JavaScript?

前端 未结 3 439
醉话见心
醉话见心 2020-12-25 12:59

I\'m getting my head wrapped about currying and other techniques using Function.prototype.bind.
It seems extremely useful to change function scope (i.e., this

3条回答
  •  时光取名叫无心
    2020-12-25 13:28

    I thought it would be useful to illustrate Win32's answer with a picture.

    A wrapper generated by bind makes sure your function is called with given context no matter what.
    Such wrapper will always ignore its own context.

    Given a chain of wrappers, any context but the innermost is lost.
    Therefore, there is no way to change the context once it has been set using bind.

    Chained bind calls

提交回复
热议问题