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

javascript ÖÐcallÓëapplyÇø±ð

1.call·½·¨
¹Ù·½£¨JavaScriptÊֲᣩ£º
µ÷ÓÃÒ»¸ö¶ÔÏóµÄÒ»¸ö·½·¨£¬ÒÔÁíÒ»¸ö¶ÔÏóÌæ»»µ±Ç°¶ÔÏó¡£
call([thisObj[,arg1[,
arg2[,   [,.argN]]]]])
²ÎÊý
thisObj  ¿ÉÑ¡Ïî¡£½«±»ÓÃ×÷µ±Ç°¶ÔÏóµÄ¶ÔÏó¡£
arg1, arg2,  , argN
¿ÉÑ¡Ïî¡£½«±»´«µÝ·½·¨²ÎÊýÐòÁС£
  
˵Ã÷
call ·½·¨¿ÉÒÔÓÃÀ´´úÌæÁíÒ»¸ö¶ÔÏóµ÷ÓÃÒ»¸ö·½·¨¡£call
·½·¨¿É½«Ò»¸öº¯ÊýµÄ¶ÔÏóÉÏÏÂÎÄ´Ó³õʼµÄÉÏÏÂÎĸıäΪÓÉthisObjÖ¸¶¨µÄжÔÏó¡£
Èç¹ûûÓÐÌṩ thisObj ²ÎÊý£¬ÄÇô Global ¶ÔÏó±»ÓÃ×÷ thisObj¡£
2.apply·½·¨
¹Ù·½£¨JavaScriptÊֲᣩ£º
Ó¦ÓÃijһ¶ÔÏóµÄÒ»¸ö·½·¨£¬ÓÃÁíÒ»¸ö¶ÔÏóÌæ»»µ±Ç°¶ÔÏó¡£
apply([thisObj[,argArray]])
²ÎÊý
thisObj  ¿ÉÑ¡Ïî¡£½«±»ÓÃ×÷µ±Ç°¶ÔÏóµÄ¶ÔÏó¡£
argArray ¿ÉÑ¡Ïî¡£½«±»´«µÝ¸ø¸Ãº¯ÊýµÄ²ÎÊýÊý×é¡£
˵Ã÷
Èç¹û argArray ²»ÊÇÒ»¸öÓÐЧµÄÊý×é»òÕß²»ÊÇ arguments ¶ÔÏó£¬ÄÇô½«µ¼ÖÂÒ»¸ö TypeError¡£
Èç¹û
ûÓÐÌṩ argArray ºÍ thisObj ÈκÎÒ»¸ö²ÎÊý£¬ÄÇô Global ¶ÔÏ󽫱»ÓÃ×÷ thisObj£¬ ²¢ÇÒÎÞ·¨±»´«µÝÈκβÎÊý¡£
  
Á½ÕßµÄÇø±ð£º
Á½
ÕßʵÏֵŦÄÜÊÇÍêȫһÑùµÄ£¬Ö»ÊDzÎÊý´«µÝ·½Ê½²»Ò»Ñù£¬callÊǽ«¸÷¸ö²ÎÊýÒÔ¶ººÅ£¨,£©¸ô¿ª£¬¶øapplyÊǽ«ËùÓвÎÊý×é³ÉÒ»¸öÊý×é½øÐд«µÝ¡£
²Î¿¼´úÂ룺
function fun_one() {
    
this.a = "I'm string a";
     this.b = "I'm string b";
  
    
//䶨Òåthis.c£¬µ«µ÷ÓõÄÊÇfun_twoÀïÃæµÄ£¬ËùÒÔ¶¨²»¶¨Òå¶¼ÎÞËùν;
     this.fun =
function(p1,p2) {
        var s = "this.a: " + this.a + "\nthis.b: " +
this.b + "\nthis.c: " + this.c + "\n\nÆäËü²ÎÊý£º\np1="+p1+"\np2="+p2;
       
alert(s);
     }
}
 
 function fun_two() {
     
this.b = "I'm other string b";
    
//䶨Òåthis.a£¬ËùÒÔ·µ»Øundefined
     this.c = "I'm string c";
 }
 var obj1 = new fun_one(); 
 var
obj2 = new fun_two();
 /*
 &n


Ïà¹ØÎĵµ£º

javascriptʼþ²éѯ×ÛºÏ

click() ¶ÔÏó.click() ʹ¶ÔÏó±»µã»÷¡£
closed ¶ÔÏó.closed ¶ÔÏó´°¿ÚÊÇ·ñÒѹرÕtrue/false
clearTimeout(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetTimeout¶ÔÏó
clearInterval(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetInterval¶ÔÏó
confirm("ÌáʾÐÅÏ¢") µ¯³öÈ·ÈÏ¿ò£¬È·¶¨·µ»ØtrueÈ¡Ïû·µ»Øfalse
cursor:Ñùʽ ¸ü¸ÄÊó±êÑùʽ hand crosshair text wait help defa ......

JavaScript±Ê¼Ç ÓïÑÔ»ù´¡

ÐèÒªÁ˽âµÄHTML֪ʶ
       ±êÇ© table,tr,th,td
 
ÓÃÑ­»·½øÐÐÖØ¸´²Ù×÷
       for(;;){}
 
javascript×Ö·û´®
       ÔÚjavascriptÖУ¬µÚÒ»¸ö×Ö·ûÔÚλÖÃ0ÉÏ¡£cat£¬cÔÚλÖÃ0ÉÏ£¬aÔÚλÖÃ1É ......

ʵÓÃµÄ JavaScript ²âÊÔ¼°Ð§Ñ鹤¾ß

JavaScript ÊÇÒ»¿îÇ¿´óµÄ¹ã·ºÔËÓÃÓÚÏÖ´úWebÕ¾µã¼°Ó¦ÓõĽű¾ÓïÑÔ¡£×÷Ϊһ¸ö¼¼ÒÕ¾«Õ¿µÄ Web ¿ª·¢Õߣ¬ÕÆÎÕJavaScript¿ÉÒÔÔöÇ¿Óû§µÄʹÓÃÌåÑ飬Ìṩ½»»¥¼°¸»¿Í»§¶ËµÈ¹¦ÄÜ¡£
¾¡¹ÜJavaScript µÄÓï·¨·Ç³£¼òµ¥£¬µ«¶ÔÓÚд³ÌÐò¶øÑÔÈÔÈ»ÊÇÀ§ÄÑÖØÖØ£¬¾ÍÊÇÒòΪËüµÄÔËÐл·¾³£º»ùÓÚWebä¯ÀÀÆ÷¡£
ÒÔÏÂÄú¿ÉÒÔ¿´µ½ÊÕ¼¯µÄ8¸öʵÓÃµÄ JavaScrip ......

javascript¼¼ÇÉ

1¡¢×Ö·û´®×ª»»ÎªÊýÖµ
³£¹æ·½·¨£º
JScript code
var a = parseFloat("12");
var b = parseInt("34");
¿ÉÒÔÓÃ
JScript code
var a = +("12");
var b = +("34");
2¡¢¶àάÊý×é
³£¹æ·½·¨£º
JScript code
var A = new Array(2);
A[0] = new Array(2);
A[1] = new Array(2);
A[0][0] = 1;
A[0][1] = 2;
A[1][0] = ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ