What you're doing is (almost) equivalent to this:
"use strict";
function test(a) {
console.log(a);
}
val t = new test(undefined);
t(window);
Just remove the new
keyword:
"use strict";
(function test(a) { console.log(a); })(window);
Frage
When running this snippet
"use strict";
(new function test(a) { console.log(a); })(window);
Why do I get undefined
for a
? Why isn't the window passed to the anonymous function?
Lösung
What you're doing is (almost) equivalent to this:
"use strict";
function test(a) {
console.log(a);
}
val t = new test(undefined);
t(window);
Just remove the new
keyword:
"use strict";
(function test(a) { console.log(a); })(window);