There is something I don\'t understand about how eval works. Suppose I have a function foo:
function foo() { console.log(\"test\"); }
A
Put brackets around your function
eval("(function foo() { console.log(\"foo\"); })()");
It is like calling
(function foo() { console.log("foo"); })()