After looking at this answer I became curious if it was possible to reassign addTogether.bind
so that you could call it without the context argument. Some of the different methods I've tried are below:
// these are intended as separate attempts, don't execute all of them sequentially
addTogether.bind = addTogether.bind.bind(addTogether.bind);
addTogether.bind = addTogether.bind.bind(addTogether.bind(addTogether));
addTogether.bind = addTogether.bind.bind(addTogether);
addTogether.bind = addTogether.bind(addTogether);
My intention is to allow this:
function addTogether(a,b) {
return a+b;
}
// something here to make the following possible
console.log(typeof addTogether.bind(2)); // "function"
console.log(addTogether.bind(2)(3)); // 5
console.log(addTogether(2,3)); // 5