Could someone help me understand why new Function does not work here?
var fn = data["callback"]; // String with value: function() { anotherFunctionToRun(); }
var foo = new Function("return ("+fn+")");
foo();
alert(foo) // returns function anonymous() { return function () {anotherFunctionToRun();}; }
alert(foo()) // function () { anotherFunctionToRun(); }
foo(); // Wont do anything
Is there something wrong with my syntax?