The eval global Function Dojo Loader will see one of the following functions
var Eval_ = new Function (' Return eval (arguments[0); '); function functions run at the top-level scope, but run more efficiently, but using this method does not pollute the global variables and call the top-level scope eval (' var i = 100; '); alert (i); Eval_ (' var b = 100 '); alert (b); Error, B does not define var where = ' I am abroad '; Global scope where function test () {var where = ' I'm in the country ';//The Where EVAL_ of the closure (' Alert (where) ');//I'm abroad, global scope Eval (' Alert (where) ');//I am in the domestic, local full-use domain window.eval (' alert (where) '); I'm abroad IE6/7/8 I'm in the country. Global scope can be used, execscript} test ()
There will also be an eval function in Dojo's Kernal module, and the code and explanation are as follows
(Function ("D", "D.eval = function () {return d.global.eval?") D.global.eval (Arguments[0]): eval (arguments[0]);}) (dojo);/*=====dojo.eval = function (scripttext) {// try to execute the corner string (scripttext) under the global scope, except IE cannot support, other browsers can execute correctly under the global scope , IE executes dojo.eval (' var pi = 3.14 '); Alert (PI) //pi undefined; To execute the global variable dojo.eval ("Window.pi = 3.14") in IE; The global variable is executed under IE, only execscript is used, but it does not return a value and cannot terminate execution.
JavaScript in-depth knowledge of JavaScript basics