Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 stuffs

Primitive types
1. undefined, null, boolean, number, string; undefined is derived from null.
e.g. var tmp; typeof tmp == undefined.
e.g. void(javascript:aler(¡®x¡¯)) == undefined.
e.g. undefined==null
2. NaN!=NaN isNaN(¡°123¡±)==false isNaN(¡°blue¡±)==true ......

JavaScript ÖÆ×÷¼òµ¥¼ÆËãÆ÷ isNaN eval ʹÓÃ

Åжϣ¨value£©ÊÇ·ñÊÇÒ»¸öÊý×Ö£¬¼ÙÈçÖµÊÇNaNÄÇôIsNan·µ»ØTRUE£¬·ñÔò·µ»ØFALSE¡£
»¹ÓÐÒ»ÖÖ°ì·¨£¬±äÁ¿¿ÉÒÔÓëËü×ÔÉí½øÐбȽϡ£ ¼ÙÈç±È½ÏµÄ½á¹û²»µÈ£¬ÄÇôËü¾ÍÊÇ NaN ¡£
ÕâÊÇÒòΪ NaN ÊÇΨһÓë×ÔÉí²»µÈµÄÖµ¡£
µÚÒ»ÖÖ·½·¨£º
<html>
<head>
<title>¼òµ¥¼ÆËãÆ÷µÄÖÆ×÷</title>
</ ......

JavascriptÃæÏò¶ÔÏó±à³Ì£¨¶þ£©£º¼Ì³Ð


ZT:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_inheritance.html
ÉÏÒ»´ÎµÄÎÄÕ£¬Ö÷Òª½éÉÜÁËÈçºÎ"·â×°"Êý¾ÝºÍ·½·¨£¬´ÓÔ­ÐͶÔÏóÉú³ÉʵÀý¡£
½ñÌìÒª½éÉܵÄÊÇ£¬¶à¸öÔ­ÐͶÔÏóÖ®¼äÈçºÎ"¼Ì³Ð"¡£
±ÈÈ磬ÏÖÔÚÓÐÒ»¸ö"¶¯Îï"¶ÔÏó£¬
¡¡¡¡function Animal(){
¡¡¡¡¡¡¡¡this.species = "¶¯Îï";
¡¡¡¡}
»¹ÓÐ ......

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´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......

javascript location.reload()

¹¦ÄÜ£º
ÖØмÓÔØÎĵµ¡£
Óï·¨£º
location.reload(force)
²ÎÊý£º
force£º¿ÉÑ¡²ÎÊý£¬ÊÇÒ»¸ö²¼¶ûÖµ¡£
      Èç¹ûÊ¡ÂÔ²ÎÊý£¬»òÕß²ÎÊýÊÇfalse£¬Ëü¾Í»áÓÃHTTPÍ·If-Modified-SinceÀ´¼ì²â·þÎñÆ÷ÉϵÄÎĵµÊÇ·ñÒѸı䡣Èç¹ûÎĵµÒѸÄ
±ä£¬reload()»áÔÙ´ÎÏÂÔظÃÎĵµ¡£Èç¹ûÎĵµÎ´¸Ä±ä£¬Ôò¸Ã·½·¨½«´Ó»º´æÖÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ