//calling test1 will **not** define a function you can call in the global scope //functions defined in eval are scoped to the function they're called from function test1() { eval('function boo(){alert("No one can call me.")}'); } boo(); //boo() is not defined error //calling test2 **will** define a function you can call in the global scope //the window object and the global scope are the same things in javascript function test(){ eval('window.boo = function (){alert("Boo! Did I scare you?")}'); }; boo(); //alert window will show