Bind function without thisArg

Sultan thysultan at gmail.com
Mon Jan 14 05:38:49 UTC 2019


Consider the following example:

var foo = (function(a) { console.assert(this === obj) }).bind(undefined, 1)
var obj = {foo: foo}

Calling foo from obj:

obj.foo(1)

Would result in an assertion. How does one go about preserving the this
reference of the caller. That is i want to use .bind to only bind
"arguments" and not "thisArg".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190114/52faa474/attachment.html>


More information about the es-discuss mailing list