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)
À´½âÎöµÄ¡£
Ïà¹ØÎĵµ£º
ÎÒÃǶ¼ÖªµÀjava¡¢c#¡¢vbµÈÓïÑÔ¶¼ÓÐsleepÔÝÍ£µÄº¯Êý£¬¶øJavaScript½Å±¾Ã»ÓÐÀàËƵŦÄÜ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄʵÏֵķ½·¨£º
<mce:script type="text/javascript"><!--
function test()
{
var s="javascript--ÔÝÍ£º¯Êý";
setTimeout(
function(){
eval(sleep(test)); //Ö´ÐÐreturnÖ®ºóµÄ´úÂ룬Ҳ¾ÍÊÇ&ldq ......
JavaScript³£ÓÃÑéÖ¤º¯Êý
Òý×Ô:http://www.webdeveloping.cn/blog/?action=show&id=209
//УÑéÊÇ·ñÈ«ÓÉÊý×Ö×é³É
function isDigit(s) {
var patrn=/^[0-9]{1,20}$/;
i ......
ÔÚÊý°ÙÍòÕÅÒ³ÃæÖУ¬JavaScript ±»ÓÃÀ´¸Ä½øÉè¼Æ¡¢ÑéÖ¤±íµ¥¡¢¼ì²âä¯ÀÀÆ÷¡¢´´½¨cookies£¬µÈµÈµÈµÈ¡£
JavaScript ÊÇÒòÌØÍøÉÏ×îÁ÷ÐеĽű¾ÓïÑÔ£¬²¢ÇÒ¿ÉÔÚËùÓÐÖ÷ÒªµÄä¯ÀÀÆ÷ÖÐÔËÐУ¬±È·½Ëµ Internet
Explorer¡¢ Mozilla¡¢Firefox¡¢Netscape¡¢ºÍ Opera¡£
......
Èç¹ûÄú»¹Ã»ÓÐÔĶÁ¡¶JavaScriptµ÷ÊÔ¼¼ÇÉÖ®£º¿ìËÙ¶¨Î»¡·£¬½¨ÒéÏÈ¿´¿´ÄÇƪ¡£Ëµ²»¶¨£¬ÓÿìËÙ¶¨Î»¾ÍÄܽâ¾öÎÊÌâÁË£¬ºÇºÇ¡£Õâ´ÎÎÒ»á×ܽá¼Ç¼һ϶ϵãµ÷ÊԵıʼǣ¬Ï£ÍûÒ²¶Ô´ó¼ÒÓÐÓ㬻¶Ó²¹³ä½»Á÷£¡
Ê×ÏÈ£¬ÔÚ¸÷¸öä¯ÀÀÆ÷ÖУ¬¶Ïµãµ÷ÊÔÖ§³ÖµÄ×îºÃµÄµ±È»ÊÇFirefox£¬Firefox²»½ö¿ÉÒÔʹÓÃFirebugµ÷ÊÔÒ³Ãæjs½Å±¾£¬»¹¿ÉÒÔÓø߼¶µ÷ÊÔ¹¤¾ßÀ ......