0

I was just wrapping my head around this

var bindable = Function.bind.bind(Function.bind);

Now, I think the key to understanding this problem would be a scenario of how this is used. I can imagine its useful but I can't think of any example. Can someone provide me a usage example ?

Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
  • See http://stackoverflow.com/questions/23482982/how-does-function-bind-bindfunction-call-uncurry – Denys Séguret Mar 16 '15 at 19:51
  • I've seen that post. Please not I'm not looking for an explanation, but examples. In that post none is given! – Jeanluca Scaljeri Mar 16 '15 at 19:54
  • @JeanlucaScaljeri: Maybe you want to read the answers, not only the question? Both do give examples. See also the "Linked" posts on the duplicate question. – Bergi Mar 16 '15 at 20:05
  • They give only examples of Function.bind.bind(Function.call) if I'm not mistaken – Jeanluca Scaljeri Mar 16 '15 at 20:07
  • Oh right, that's the other expression. However, here's your example: `uncurryThis = bindable(Function.call)` :-) – Bergi Mar 16 '15 at 20:08
  • I think you do know what you're talking about :) But what you suggests simply transform it back into a `callable`. And I'm specifically interested in `bindable` usage? – Jeanluca Scaljeri Mar 16 '15 at 20:15
  • 1
    @JeanlucaScaljeri: You could think of class methods that need to be bound to instances. `var getMethod = bindable(function(…) { … })`. Then, in your constructor, you can do `this.method = getMethod(this)` – Bergi Mar 16 '15 at 20:57
  • 1
    @JeanlucaScaljeri I'm racking my brains to find something really useful for it, but an interesting property of bindable is that `bindable`, `bindable(f)`, and `bindable(f)(obj)` are all first-class functions that can be passed around and used as callbacks or elements in a collection. So, for example, you could do [this](http://jsfiddle.net/hu6ayLcx/) to bind all of a prototype's methods to an object in bulk. – JLRishe Mar 16 '15 at 21:02
  • really great examples, thanks a lot!! – Jeanluca Scaljeri Mar 16 '15 at 21:29

0 Answers0