Is there any way to pass this
into an Immediately-Invoked Function Expression, without resolving to var that = this
(which isn't applicable on some cases)?
Tried the following but with no luck:
(function(that) {
console.log(that);
})(this)
Is there any way to pass this
into an Immediately-Invoked Function Expression, without resolving to var that = this
(which isn't applicable on some cases)?
Tried the following but with no luck:
(function(that) {
console.log(that);
})(this)
You might be able to use
call
orapply
for this purpose. For example:The code should work, make sure there is no code before it without a semicolon.
You could try the code below, which will be ok even the code before it omit the semicolon.