Eval is the code that is passed to it in the scope of caller:
var x = ' outer '; (function () {var x = ' inner '; Eval (' x '); "Inner"}) (); In ES5, can be divided into direct call or indirect call, and whether in strict mode call (1,eval) (' a ") for indirect call, (1,eval) still return an eval function also below these are also non-direct calls: (eval , eval) (' ... ') (1 eval:0) (' ... ') (__ = eval) (' ... ') var e = eval; E (' ... ') (function (e) {e (' ... ')}) (eval) (function (e) {return e}) (eval) (' ... ') (function () {arguments[0] (' ... ')}) (eval This.eval (' ... ') this[' eval '] (' ... ') [eval][0] (' ... ') eval.call (this, ' ... ') eval (' eval ') (' ... ')The direct call is only when Eval points to standard, built-in function (eval is not overwritten or is not a replica):Eval = (function (eval) {return function (expr) {return eval (expr); }; }) (eval); Eval (' + + '); It looks like a direct call, but really was an indirect one. It's because ' eval ' resolves to a custom function, rather than standard, built-in one these are direct calls: eval (' ... ') (eval) (‘...‘) (((eval))) (‘...‘) (function () {return eval (' ... ')}) () eval (' eval (... ') ') (function (eval) {return eval (' ... ');}) (eval) with ({eval:eval}) eval (' ... ') with (window) eval (' ... ')If Eval is a reference pointer, it is called directly, and if it is a value, it is called indirectly.Eval (' + + ') Here the Eval is a reference that needs to be executed, followed by a standard, built-in function object (1,eval) (' + + '), and (1,eval) execution result is a value, not a reference (eval) The execution result is still a reference, not a value, because the parentheses do not execute the expression inside it (does not evaluate it expression), so a reference is passed in, and the return is still a reference http://perfectionkills.com/ global-eval-what-are-the-options/
Global scope eval