Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[·­Òë]High Performance JavaScript(007)

Dynamic Scopes  ¶¯Ì¬×÷ÓÃÓò
    Both the with statement and the catch clause of a try-catch statement, as well as a function containing eval_r(), are all considered to be dynamic scopes. A dynamic scope is one that exists only through execution of code and therefore cannot be determined simply by static analysis (looking at the code structure). For example:
    ÎÞÂÛÊÇwith±í´ïʽ»¹ÊÇtry-catch±í´ïʽµÄcatch×Ӿ䣬ÒÔ¼°°üº¬eval_r()µÄº¯Êý£¬¶¼±»ÈÏΪÊǶ¯Ì¬×÷ÓÃÓò¡£Ò»¸ö¶¯Ì¬×÷ÓÃÓòÖ»Òò´úÂëÔËÐжø´æÔÚ£¬Òò´ËÎÞ·¨Í¨¹ý¾²Ì¬·ÖÎö£¨²ì¿´´úÂë½á¹¹£©À´È·¶¨£¨ÊÇ·ñ´æÔÚ¶¯Ì¬×÷ÓÃÓò£©¡£ÀýÈ磺
function execute(code) {
  eval_r(code);
  function subroutine(){
    return window;
  }
  var w = subroutine();
  //what value is w?
};
    The execute() function represents a dynamic scope due to the use of eval_r(). The value of w can change based on the value of code. In most cases, w will be equal to the global window object, but consider the following:
    execute()º¯Êý¿´ÉÏÈ¥ÏñÒ»¸ö¶¯Ì¬×÷ÓÃÓò£¬ÒòΪËüʹÓÃÁËeval_r()¡£w±äÁ¿µÄÖµÓëcodeÓйء£´ó¶àÊýÇé¿öÏ£¬w½«µÈ¼ÛÓÚÈ«¾ÖµÄwindow¶ÔÏ󣬵«ÊÇÇ뿼ÂÇÈçÏÂÇé¿ö£º
execute("var window = {};")
    In this case, eval_r() creates a local window variable in execute(), so w ends up equal to the local window instead of the global. There is no way to know if this is the case until the code is executed, which means the value of the window identifier cannot be predetermined.
    ÕâÖÖÇé¿öÏ£¬eval_r()ÔÚexecute()º¯ÊýÖд´½¨ÁËÒ»¸ö¾Ö²¿window±äÁ¿¡£ËùÒÔw½«µÈ¼ÛÓÚÕâ¸ö¾Ö²¿window±äÁ¿¶ø²»ÊÇÈ«¾ÖµÄÄǸö¡£ËùÒÔ˵£¬²»ÔËÐÐÕâ¶Î´úÂëÊÇûÓа취Á˽â¾ßÌåÇé¿öµÄ£¬±êʶ·ûwindowµÄÈ·Çк¬Òå²»ÄÜÔ¤ÏÈÈ·¶¨¡£
    Optimizing JavaScript engines such as Safari's Nitro try to speed up identifier resolution by analyzing the code to determine which variables should be accessible at any given time. These engines try to avoid the traditional scope chain lookup by inde


Ïà¹ØÎĵµ£º

ͨ¹ýjavascript»ñµÃurl²ÎÊý

Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£ 
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......

JavaScriptʵÏÖÒ³Ãæ´«Öµ

ÎÒ»¹ÊDzËÄñ£¬Çë´ó¼Ò¶àÖ¸½Ì£¡
Ò³ÃæÒ»£º
<html>
 <head>
  <title> Ò³Ãæ´«ÖµÒ» </title>
  <script>
    function funShow()
 {
    var arr=new Array(6);
       var arrs = showModalDialog("Ò³ ......

JavaScript ¹æ·¶±àд

×î½ü±àдJavascript´úÂë¡£Æð³õû¹ÜÄÇô¶à¡£Ò»Õó¿ñд¡£´úÂëдµÃ²î²»¶àÁË¡£½á¹ûÉϰÙKÎļþ¼¸Ê®¸ö¡£µ±È» û°ì·¨ÐèҪѹËõÁË¡£ÎªÁËËÙ¶È¡£
ÕÒѹËõ¹¤¾ß¡£ÅªÁËÏ¡£½á¹û´íÎóÒ»´ó¶Ñ¡£×îºó²Å·¢ÏÖÊÇ×Ô¼ºÐ´µÄ´úÂë²»¹æ·¶µ¼Öµġ£¼ì²éÁ˰ëÌìÐÞÕýÁ˼¸Ê®¸öµØ·½¡£ÖÕÓÚÄÜѹËõÁË¡£
ÏÂÃæ×ܽáÏÂÐèҪעÒâµÄµØ·½
1¡¢¶ÔÏó½áβ function½áβ ×î ......

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ