[·Òë]High Performance JavaScript(006)
Identifier Resolution Performance ±êʶ·ûʶ±ðÐÔÄÜ
Identifier resolution isn't free, as in fact no computer operation really is without some sort of performance overhead. The deeper into the execution context's scope chain an identifier exists, the slower it is to access for both reads and writes. Consequently, local variables are always the fastest to access inside of a function, whereas global variables will generally be the slowest (optimizing JavaScript engines are capable of tuning this in certain situations). Keep in mind that global variables always exist in the last variable object of the execution context's scope chain, so they are always the furthest away to resolve. Figures 2-4 and 2-5 show the speed of identifier resolution based on their depth in the scope chain. A depth of 1 indicates a local variable.
±êʶ·ûʶ±ð²»ÊÇÃâ·ÑµÄ£¬ÊÂʵÉÏûÓÐÄÄÖÖµçÄÔ²Ù×÷¿ÉÒÔ²»²úÉúÐÔÄÜ¿ªÏú¡£ÔÚÔËÐÐÆÚÉÏÏÂÎĵÄ×÷ÓÃÓòÁ´ÖУ¬Ò»¸ö±êʶ·ûËù´¦µÄλÖÃÔ½ÉËüµÄ¶ÁдËٶȾÍÔ½Âý¡£ËùÒÔ£¬º¯ÊýÖоֲ¿±äÁ¿µÄ·ÃÎÊËÙ¶È×ÜÊÇ×î¿ìµÄ£¬¶øÈ«¾Ö±äÁ¿Í¨³£ÊÇ×îÂýµÄ£¨ÓÅ»¯µÄJavaScriptÒýÇæÔÚijЩÇé¿öÏ¿ÉÒԸıäÕâÖÖ×´¿ö£©¡£Çë¼Çס£¬È«¾Ö±äÁ¿×ÜÊÇ´¦ÓÚÔËÐÐÆÚÉÏÏÂÎÄ×÷ÓÃÓòÁ´µÄ×îºóÒ»¸öλÖã¬ËùÒÔ×ÜÊÇ×îÔ¶²ÅÄÜ´¥¼°µÄ¡£Í¼2-4ºÍ2-5ÏÔʾÁË×÷ÓÃÓòÁ´Éϲ»Í¬Éî¶È±êʶ·ûµÄʶ±ðËÙ¶È£¬Éî¶ÈΪ1±íʾһ¸ö¾Ö²¿±äÁ¿¡£
Figure 2-4. Identifier resolution for write operations
ͼ2-4 д²Ù×÷µÄ±êʶ·ûʶ±ðËÙ¶È
Figure 2-5. Identifier resolution for read operations
ͼ2-5 ¶Á²Ù×÷µÄ±êʶ·ûʶ±ðËÙ¶È
The general trend across all browsers is that the deeper into the scope chain an identifier exists, the slower it will be read from or written to. Browsers with optimizing JavaScript engines, such as Chrome and Safari 4, don't have this sort of performance penalty for accessing out-of-scope identifiers, whereas Internet Explorer, Safari 3.2, and others show a more drastic effect. It's worth noting that earlier browsers, such as Internet Explorer 6 and Firefox 2, had incredibly steep slopes and would no
Ïà¹ØÎĵµ£º
javascriptµÄhistory.go(-1)
echo '<script language="javascript">{alert("ÁôÑÔ²»ÄÜΪ¿Õ!");history.go(-1);}</script>';}
echo '<script language="javascript">{alert("ÁôÑÔ²»ÄÜΪ¿Õ!");return true;}</script>';}
ÕâÊDz»Ë¢ÐÂÒ³ÃæµÄ·½Ê½ ......
javascriptÈëÃÅ»ù´¡ÖªÊ¶
ÎÄÕÂÔ´ÓÚ²©¿Í£ºhttp://www.cnblogs.com/seesky/articles/1433526.html
ÔÚÍøÕ¾ÖÆ×÷µÄ¹ý³ÌÖо³£ÐèÒªÓõ½JavaScriptÓï¾ä£¬ÕÆÎÕһЩÏà¹ØµÄJavaScript½á¹¹¶ÔÍøÕ¾ÖÆ×÷ÓÐ×ÅÖØµÄÖØÓã¡
1.document.write(""); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
......
ѧϰJavascript£¬×îÄѵĵط½ÊÇʲô£¿
ÎÒ¾õµÃ£¬Object£¨¶ÔÏó£©×îÄÑ¡£ÒòΪJavascriptµÄObjectÄ£ÐͺܶÀÌØ£¬ºÍÆäËûÓïÑÔ¶¼²»Ò»Ñù£¬³õѧÕß²»ÈÝÒ×ÕÆÎÕ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄѧϰ±Ê¼Ç£¬Ï£Íû¶Ô´ó¼ÒѧϰÕâ¸ö²¿·ÖÓÐËù°ïÖú¡£ÎÒÖ÷Òª²Î¿¼ÁËObject-Oriented JavaScriptºÍProfessional JavaScript for Web Developers (2nd Edition)ÕâÁ½±¾Êé¡£ ......
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´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......
¹¦ÄÜ£º
ÖØÐ¼ÓÔØÎĵµ¡£
Óï·¨£º
location.reload(force)
²ÎÊý£º
force£º¿ÉÑ¡²ÎÊý£¬ÊÇÒ»¸ö²¼¶ûÖµ¡£
Èç¹ûÊ¡ÂÔ²ÎÊý£¬»òÕß²ÎÊýÊÇfalse£¬Ëü¾Í»áÓÃHTTPÍ·If-Modified-SinceÀ´¼ì²â·þÎñÆ÷ÉϵÄÎĵµÊÇ·ñÒѸı䡣Èç¹ûÎĵµÒѸÄ
±ä£¬reload()»áÔÙ´ÎÏÂÔØ¸ÃÎĵµ¡£Èç¹ûÎĵµÎ´¸Ä±ä£¬Ôò¸Ã·½·¨½«´Ó»º´æÖÐ ......