How can I call Function.prototype.bind with an array of arguments, as opposed to hardcoded arguments? (Not using ECMA6, so no spread operator).
I\'m trying to put a
.bind
is a normal function, so you can call .apply
on it.
All you have to do is pass the original function as the first param and the desired THIS
variable as the first item in the array of arguments:
bound = db.find.bind.apply(db.find, [null].concat(arguments));
// ^-----^ ^-----^ THIS
Whether that can be considered cleaner or not is left to the reader.