I would bind my function directly when declaring my function, the following attempt fails:
(function f() {
return this.a;
}).bind({a: 'qwerty'});
var g = f()
console.log("g: ", g)
how achieve this result?
Any hint would be great, thanks
You need an assignment of the bound function. Function#bind returns a new function.
var f = function () {
return this.a;
}.bind({ a: 'qwerty' }),
g = f()
console.log("g:", g);