Vote count:
0
I've seen this little snippet of code floating around before and never really taken the time to wrap my head around what it does.
var bind = Function.bind;
var call = Function.call;
var bindable = bind.bind(bind);
var callable = bindable(call);
I understand in concept and in practice what .bind
and .call
do, but what is the benefit, advantage or practical use of creating the bindable
and callbable
functions above?
Below is a contextual example of a use case for bindable.
var bound = bindable(db.find, db).apply(null, arguments);
var findable = bindable(db.find, db);
var bound = findable.apply(null, arguments);
var bound = findable(1, 2, 3);
What can this pattern be used for?
asked 30 secs ago
What are the uses for the bindable and callable pattern?
Aucun commentaire:
Enregistrer un commentaire