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

JavaScriptÖÐÄäÃûº¯Êý£¬º¯ÊýÖ±½ÓÁ¿ºÍ±Õ°ü(ת)

Ô­Îijö´¦: http://www.dnew.cn/post/196.htm
ÏÈ¿´ÏÂÏÂÃ漸ÖÖд·¨
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
µÚÒ»ÖÖÎÒÃÇÓ¦¸Ã¶¼ºÜÊìϤÁË£¬ÕâÊÇÎÒÃǾ­³£Ê¹ÓõÄд·¨¡£µÚ¶þµÚÈýÖÖ¶¼ÊÇÄäÃûº¯ÊýµÄд·¨¡£
--------------------------------------------------------------------------------
µÚ¶þÖÖ
¿ÉÒÔÕâÑùÀí½â£º
•var f=function(x) {return x*x;};f()
ÄÇÎÒÃDz»Í¨¹ýfÕâ¸ö±äÁ¿À´ÒýÓú¯Êý¾ÍÊÇ
•function(){}()
È»¶øÕâÑù¿Ï¶¨ÊÇ´íÎóµÄ¾ÍÏñ
•var f=1+2;
•f=f*0;
Óë
•var f=1+2*0;
½á¹û²»Í¬Ò»Ñù¡£
ÒªµÃµ½ÕýÈ·½á¹ûÖ»ÄÜ£º
•f=(1+2)*0;
Ò²¾ÍÊÇÒªÃ÷È·µÄ±êʶ³ö³ÌÐò¿é,¼´£º
•(function(){})()
¿ÏÄãÓÐÒÉÎÊ£ºÀ¨ºÅ“()”µ½µ×ÊDz»ÊÇÆðµ½Á˱êʶ´úÂë¿éµÄ×÷Óã¿
ÎÒÃÇ¿ÉÒÔÓÃJavaScriptµÄÄÚÖú¯Êý¼ì²âһϣ¡
¾ÙÒ»¸ö×î¼òµ¥µÄÀý×Ó£º
•alert(4)
Õâ¶Î´úÂë»áµ¯³öÌáʾÄÚÈÝÊÇ“4”
¸Ä³ÉÕâÑù
•(alert)(4)
¿ÉÒÔ¿´µ½Ö´ÐеÄЧ¹ûºÍÉÏÒ»¶Î´úÂëÒ»Ñù¡£
ÕâÖÖÐÎʽµÄº¯ÊýÖ´ÐÐÒ²±»ºÜ¶àJavaScript¿ò¼ÜËù²ÉÓá£
--------------------------------------------------------------------------------
µÚÈýÖÖ£¬Èç¹ûÄãÓùýjsvm¿ò¼ÜµÄ»°¾Í»á·¢ÏÖÀïÃæµÄ´úÂëʹÓÃÁËÕâÖÖÐÎʽ¡£
ÄÇÈçºÎ½âÊ͵ÚÈýÖÖÇé¿öÄØ?
ΪÁËŪÃ÷°×ä¯ÀÀÆ÷ÊÇÈçºÎÀí½âÕâÑùµÄд·¨µÄ£¬ÎÒÃÇ¿ÉÒÔÀûÓÃÒ»ÏÂMozilla FirefoxµÄ´íÎó¿ØÖÆ̨¹¦ÄÜ¡£
ÔÚ´úÂëÖвåÈëÒ»¶Î´íÎó´úÂ룬´úÂë¶ÎÈçÏ£º
•(function(s){s+s}(1)).splice();
´ò¿ªMozilla FirefoxµÄ´íÎó¿ØÖÆ̨£¬¿ÉÒÔ¿´µ½ÓÐÈçϵĴíÎóÌáʾ
´íÎó£º (function (s) {})(1) has no properties
Ô´Îļþ£ºfile:///C:/Documents…….html
ÐУº18
¿ÉÒÔÈÏΪ£¬ä¯ÀÀÆ÷¶ÔÓÚ
•(function(s){s+s}(1))
ÕâÑùµÄ´úÂë°´ÕÕ
•(function (s) {s+s})(1)
À´½âÎöµÄ¡£


Ïà¹ØÎĵµ£º

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

Data Format Conclusions  Êý¾Ý¸ñʽ×ܽá
    Favor lightweight formats in general; the best are JSON and a character-delimited custom format. If the data set is large and parse time becomes an issue, use one of these two techniques:
    ×ܵÄÀ´ËµÔ½ÇáÁ¿¼¶µÄ¸ñʽԽºÃ£¬× ......

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

JavaScript Minification  JavaScript½ô´Õ
    JavaScript minification is the process by which a JavaScript file is stripped of everything that does not contribute to its execution. This includes comments and unnecessary whitespace. The process typically reduces the file size by ha ......

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

Summary  ×ܽá
    When web pages or applications begin to feel slow, analyzing assets as they come over the wire and profiling scripts while they are running allows you to focus your optimization efforts where they are needed most.
    µ±ÍøÒ³»òÓ¦ÓóÌÐò±äÂýʱ£¬·ÖÎ ......

JavaScript±à³Ì±Ê¼Ç

ÐÂÖÐ……
1¡¢Êý¾ÝÀàÐÍÑéÖ¤ÎÊÌâ
  Asp.NetËäÈ»ÓÐÑéÖ¤¿Ø¼þ£¬µ«ÊÇÓÐЩ¸´ÔÓµÄÑéÖ¤»¹Êǵô«µ½·þÎñÆ÷ÉϽøÐУ¬ÓÃjsËٶȺÍÐÔÄܶ¼±È½ÏºÃ
<script>
 //¼ì²éÊÇ·ñΪÈÎÒâÊý£¨ÊµÊý£©
function isNumeric(strNumber) {
var newPar=/^(-|\+)?\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
 //¼ ......

javascript String.replaceº¯Êý

    javascriptµÄStringÀàÄÚÖú¯Êýreplace(regexp, newString)º¯ÊýÌṩÁË×Ö·û´®Ìæ»»¹¦ÄÜ£¬´Óº¯ÊýÔ­ÐÍÉÏ¿ÉÒÔ¿´³öÖ§³Ö Regular Exp¡£´Ëº¯Êý¹¦Äܷdz£ÊµÓ㬵«Ò²Óм¸¸öµØ·½Óеã»ìÏý£¬ÏÂÃæͨ¹ýʵ¼ÊµÄÀý×ÓÀ´ËµÃ÷£º
    ±ÈÈçÎÒÃÇÏÖÔÚÒªÕë¶Ô´®
var src="<a href=&quot;http://xx.com/a/2010 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ