JavaScript in-depth knowledge of JavaScript basics

Source: Internet
Author: User

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

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.