Global scope eval

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.