This is probably something stupid, but I have code like this:
var f = functionWrapper();
f.apply(this, []);
function functionWrapper() {
return new function () {
console.log("Called function");
}
}
Why does it crash and give the following error:
Uncaught TypeError: Object [object Object] has no method 'apply' test.html:28(anonymous function)
Change this:
(which immediately invokes the function as a constructor, and returns the constructed object) to this:
(which returns the function itself).