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

Javascript ÄäÃûº¯Êý¼°Æä´úÂëģʽԭÀí

֮ǰ¿´ÁËÓйØÄäÃûº¯ÊýµÄµ÷Ó㬸оõÓбØÒªºÍ´ó¼Ò·ÖÏíһϡ£
¹ØÓÚʲôÊÇÄäÃûº¯Êý£¬¼°Ëü´øÀ´µÄÓÅÊÆÔÚ±¾ÎľͲ»ÉÁË£¬ÏÈÅ׳öÒ»¸ö³£ÓõÄÄäÃûº¯Êý£º
(function(){alert('yo')})()
ºÜ¶àͬѧ֪µÀÔõôÓÃÕâÖÖÄäÃûº¯Êý£¬È´»òÐí²¢²»Ã÷°×ΪʲôÕâÑùд¾ÍÄܹ»µ÷ÓÃÄäÃûº¯Êý¡£Ò²ÐíÖªµÀºóÃæµÄÔ²À¨ºÅÊÇÖ´ÐÐÇ°ÃæµÄº¯Êý£¬¶ø²¢²»Çå³þÇ°ÃæµÄÔ²À¨ºÅ¾ßÓкÎÖÖº¬Ò壡±¾ÎĽ«´øÄãÁ˽âÄäÃûº¯ÊýµÄ´úÂëģʽԭÀí¡£
OK,ÏÈÀ´¿´¿´¸ü¶àÄäÃûº¯Êýµ÷ÓÃģʽ£º
1.
(function(){alert(1);}())
2.
(function(){alert(2);})()
3.
void function(){alert(3);}()
ÒÔÉÏ3¸ö¶¼ÊÇÕýÈ·µÄ£¬ÇÒÔÚ¹¦ÄÜÉ϶¼ÊǵÈͬµÄ¡£
ÔÙÀ´¿´Ï´íÎóµÄÊéд·½Ê½£º
4.
function(){alert('yo')}()
ÉÏÃæÕâ¶Î´úÂë»áÅ׳öÓï·¨´íÎó£¬Õ⾿¾¹ÊÇΪʲôÄØ£¿´ø×ÅÕâ¸öÎÊÌâÎÒÃÇÀ´¿´¿´Çظè¸ø³öµÄ½â´ð£º
1.º¯Êý×ÖÃæÁ¿£ºÊ×ÏÈÉùÃ÷Ò»¸öº¯Êý¶ÔÏó£¬È»ºóÖ´ÐÐËü¡£
2.ÓÅÏȱí´ïʽ£ºÓÉÓÚJavascriptÖ´Ðбí´ïʽÊÇ´ÓÔ²À¨ºÅÀïÃæµ½ÍâÃ棬ËùÒÔ¿ÉÒÔÓÃÔ²À¨ºÅÇ¿ÖÆÖ´ÐÐÉùÃ÷µÄº¯Êý¡£
3.void²Ù×÷·û£ºÓÃvoid²Ù×÷·ûÈ¥Ö´ÐÐÒ»¸öûÓÐÓÃÔ²À¨ºÅ°üΧµÄÒ»¸öµ¥¶À²Ù×÷Êý¡£ 
ºÃ°É£¬ÏȲ»¹Ü½â´ðÊÇ·ñÕýÈ·£¬ÎÒÃÇ°ÑÕâЩ·Åµ½Ò»±ß£¬ÔÙÀ´¿´¿´º¯ÊýÉùÃ÷µÄÓï·¨ºÍº¯Êý±í´ïʽµÄÓ﷨˵Ã÷£º
Ò»¡¢º¯ÊýÉùÃ÷£º
function name([param[, param[, ... param]]]) {
   statements
}
ÕâÀïµÄº¯ÊýÃû³ÆnameÊDz»¿ÉÒÔÊ¡ÂԵġ£Èç¹ûÊ¡ÂÔÁ˺¯ÊýÃû³Æ¾Í»á±¨´í¡£
ÕâÒ²ºÏÀí½âÊÍÁËΪʲôֱ½Óд
function(){alert('yo')}
»á³ö´í£¿ÒòΪ±àÒëÆ÷µ±ËûÊǺ¯ÊýÉùÃ÷¶ø´úÂëÖÐûÓгöÏÖº¯ÊýÃû³Æ£¬½á¹û¿ÉÏë¶øÖª¡£
¶þ¡¢º¯Êý±í´ïʽ£º
function [name]([param] [, param] [..., param]) {
   statements
}
º¯ÊýÃû³Æname¿ÉÒÔ±»Ê¡ÂÔ£¬Ê¡ÂÔname¾ÍÊÇËùνµÄÄäÃûº¯Êý¡£ËµÃ÷Ò»µã£ºÈç¹ûÐèÒª´´½¨ÄäÃûº¯Êý£¬Ôò±ØÐë¸ø³öÒ»¸öº¯Êý±í´ïʽ¶ø·Çº¯ÊýµÄÏÔʽÉùÃ÷
ÏÖÔÚÎÒÃÇ¿ÉÒÔ×ö³ö¸ü׼ȷµÄ½âÊÍ£º
1\2\3ÄäÃûº¯Êý´úÂëģʽֻ²»¹ýÊÇͨ¹ýÀ¨ºÅ»òÕßvoid¸æËß±àÒëÆ÷£¬°Ñfunction(){}µ±×÷º¯Êý±í´ïʽÀ´½âÊÍ°ÕÁË¡£ÕâÆäÖв¢Ã»ÓÐÄÇô¸´ÔÓµÄÓÅÏȼ¶ºÍvoid²Ù×÷·ûÔ­Àí¡£ÕâÖ»²»¹ýÊÇÒ»¸ö¼òµ¥µÄÓ﷨ת»»¡£
¿ÉÒÔÏëÏó£¬Ö»Òª·ûºÏº¯Êý±í´ïʽµÄÓï·¨£¬ÎÒÃǾͿÉÒÔ´´½¨³öNÖÖÄäÃûº¯Êý´úÂëģʽ£¬±ÈÈç
!!function(){
   alert('yo');
}()
+function(){
   alert('yo');
}()
µÈµÈµÈµÈ……
ÕâÆäÖв¢Ã»ÓÐ


Ïà¹ØÎĵµ£º

ÓÐ¹Ø JavaScript µÄ 10 ¼þÈÃÈ˷ѽâµÄÊÂÇé

JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM
API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript
ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½Óן ......

JavaScript ½âÎö¶ÁÈ¡XMLÎĵµ


JavaScript½âÎö¶ÁÈ¡XMLÎļþ£¬Ö÷Òª¾ÍÊǼÓÔز¢½âÎöXMLÎļþ£¬È»ºó¾Í¿ÉÒÔ²âÊÔ½âÎöµÄXMLÎļþµÄÄÚÈÝ£¬´òÓ¡Êä³öÀ´¡£
±àдÁËÒ»¸öJavaScriptµÄÀàÀ´ÊµÏÖ¶ÁÈ¡Ò»¸öXMLÎļþÖеÄÊý¾Ý£¬ÊµÏÖ´úÂëÈçÏÂËùʾ£º
<mce:script type="text/javascript"><!--

/**
* @author Shirdrn
*/
function XMLDoc(){}; // ¶¨ÒåÒ»¸öXM ......

JavaScriptʵÏÖÀàËÆExcel¹¦ÄÜ

//¸´ÖÆËùÑ¡±í¸ñµÄÊý¾Ýµ½¼ôÌù°å ×÷Õߣºxx
function copyData(){
var content = "";
var tbl = getTbl();
//»ñÈ¡ËùÑ¡µÄËùÓÐÊý¾Ý
for(j = start_Row; j <= end_Row; j++)
{
for(i = start_Col; i <= end_Col; i++)
{
content += (tbl.rows[j].cells[i].childNodes[0].value);
if(i != end_ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ