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

javascript ÄäÃûº¯ÊýÒÔ¼°±Õ°üµÄÌØÐÔ

ÄäÃûº¯Êý
º¯ÊýÊÇJavaScriptÖÐ×îÁé»îµÄÒ»ÖÖ¶ÔÏó£¬ÕâÀïÖ»Êǽ²½âÆäÄäÃûº¯ÊýµÄÓÃ;¡£ÄäÃûº¯Êý£º¾ÍÊÇûÓк¯ÊýÃûµÄº¯Êý¡£
1¡¢º¯ÊýµÄ¶¨Ò壬Ê×Ïȼòµ¥½éÉÜһϺ¯ÊýµÄ¶¨Ò壬´óÖ¿ɷÖΪÈýÖÖ·½Ê½
µÚÒ»ÖÖ£ºÕâÒ²ÊÇ×î³£¹æµÄÒ»ÖÖ
function double( x ){
    return 2 * x;   
}
µÚ¶þÖÖ£ºÕâÖÖ·½·¨Ê¹ÓÃÁËFunction¹¹Ô캯Êý£¬°Ñ²ÎÊýÁбíºÍº¯ÊýÌ嶼×÷Ϊ×Ö·û´®£¬ºÜ²»·½±ã£¬²»½¨ÒéʹÓá£
var double = new Function( 'x'  , ' return 2 * x;');
µÚÈýÖÖ£º
var double = function( x ) { return 2* x; }
×¢Òâ '='Óұߵĺ¯Êý¾ÍÊÇÒ»¸öÄäÃûº¯Êý£¬´´ÔìÍê±Ïº¯Êýºó£¬ÓÖ½«¸Ãº¯Êý¸³¸øÁ˱äÁ¿double¡£
2¡¢ÄäÃûº¯ÊýµÄ´´½¨
µÚÒ»ÖÖ·½Ê½£º¾ÍÊÇÉÏÃæËù½²µÄ¶¨Òåsquareº¯Êý£¬ÕâÒ²ÊÇ×î³£Óõķ½Ê½Ö®Ò»¡£
µÚ¶þÖÖ·½Ê½£º
(function( x , y){
    alert( x + y);  
})(2 ,3 );//º¯ÊýµÄ×Ôµ÷ÓõÄÐÎʽ£¬Ö±½Ó¿ÉÒԵóö½á¹û¡£
ÕâÀï´´½¨ÁËÒ»¸öÄäÃûº¯Êý(ÔÚµÚÒ»¸öÀ¨ºÅÄÚ)£¬µÚ¶þ¸öÀ¨ºÅÓÃÓÚµ÷ÓøÃÄäÃûº¯Êý£¬²¢´«Èë²ÎÊý¡£
±Õ°ü
±Õ°üµÄÓ¢Îĵ¥´ÊÊÇclosure£¬ÕâÊÇJavaScriptÖзdz£ÖØÒªµÄÒ»²¿·Ö֪ʶ£¬ÒòΪʹÓñհü¿ÉÒÔ´ó´ó¼õÉÙÎÒÃǵĴúÂëÁ¿£¬Ê¹ÎÒÃǵĴúÂë¿´ÉÏÈ¥¸ü¼ÓÇåÎúµÈµÈ£¬×ÜÖ®¹¦ÄÜÊ®·ÖÇ¿´ó¡£
±Õ°üµÄº¬Ò壺±Õ°ü˵°×Á˾ÍÊǺ¯ÊýµÄǶÌ×£¬ÄÚ²ãµÄº¯Êý¿ÉÒÔʹÓÃÍâ²ãº¯ÊýµÄËùÓбäÁ¿£¬¼´Ê¹Íâ²ãº¯ÊýÒѾ­Ö´ÐÐÍê±Ï£¨ÕâµãÉæ¼°JavaScript×÷ÓÃÓòÁ´£©¡£
ʾÀýÒ»£º
function checkClosure(){
    var str = 'rain-man';
    setTimeout(
        function(){ alert( str ); } //ÕâÊÇÒ»¸öÄäÃûº¯Êý
    , 2000);
}//Õâ¸öº¯ÊýÒªÇóÑÓ³Ù2ÃëÖ´ÐС£
checkClosure();
Õâ¸öÀý×Ó¿´ÉÏȥʮ·ÖµÄ¼òµ¥£¬×Ðϸ·ÖÎöÏÂËüµÄÖ´Ðйý³Ì»¹ÊÇÓÐÐí¶à֪ʶµãµÄ£ºcheckClosureº¯ÊýµÄÖ´ÐÐÊÇ˲¼äµÄ£¨Ò²ÐíÓÃʱֻÊÇ0.00001ºÁÃ룩£¬ÔÚcheckClosureµÄº¯ÊýÌåÄÚ´´½¨ÁËÒ»¸ö±äÁ¿str£¬ÔÚcheckClosureÖ´ÐÐÍê±ÏÖ®ºóstr²¢Ã»Óб»ÊÍ·Å£¬ÕâÊÇÒòΪsetTimeoutÄÚµÄÄäÃûº¯Êý´æÔÚÕâ¶ÔstrµÄÒýÓᣴýµ½2Ãëºóº¯ÊýÌåÄÚµÄÄäÃûº¯Êý±»Ö´ÐÐÍê±Ï,str²Å±»ÊÍ·Å¡£
ʾÀý¶þ£ºÓÅ»¯´úÂë
function forTimeout( x, y){
    alert( x + y );
}
function delay( x , y  , time ){
    setTimeout( 'forTimeout(' +  x + ',' +  y + ')' , time );    
}
/**
 *ÉÏÃæµÄdelayº¯ÊýÊ®·


Ïà¹ØÎĵµ£º

[·­Òë]PPK ̸ JavaScript µÄ this ¹Ø¼ü×Ö


Ô­ÎÄ£ºJavaScript - The this keyword
ÔÚ JavaScript ÖÐ this ÊÇ×îÇ¿µÄ¹Ø¼ü×ÖÖ®Ò»¡£ÕâƪÌùÎľÍÊÇÒª¸æËßÄãÈçºÎÓúà this¡£
ÏÂÃæÏȽ²ÈçºÎÔÚevent handling
(ʼþ´¦Àí)ÖÐÓÃËü£¬ÔÙ½Ó×ÅÊǽ² this µÄÆäËûÓ÷¨¡£
ËùÓÐÕß(Owner)
ÏÈÀ´¿´¿´º¯Êý doSomething() ÀïµÄ this ¾¿¾¹Ö¸Ïò(refer to)ÁËʲô£¿
function doSomething() { ......

Javascriptµ¥Àýģʽ

ExtJS Éè¼Æģʽ Ö®Ò» £¨µ¥Àý£©
    Extjs ·¢Õ¹ÖÁ½ñ£¬´«³ÐÁËYUIµÄΰ´ó¾«Ë裬 YUIµÃµ½ÁËDouglas Crockford£¨ÈÎÖ°ÓÚ Yahoo! µÄÒ»Ãû JavaScript ´«µÀÕߺͼܹ¹Ê¦£¬ËûÊÇÈ«Çò×îÓÐÔìÒèµÄ JavaScript ÓïÑÔר¼ÒÖ®Ò»£¬Blog£ºhttp://www.crockford.com/) ´óʦµÄÔÞͬ,¶øExtJSÒ²Êǽ«YUIµÄģʽ½Å±¾±à³ÌѧϰʹÓõÄÁÜÀ쾡Ö£ ......

JavaScript¾«´â¶ÁÊé±Ê¼Ç(5)

µÚ5Õ  ¼Ì³Ð
ÔÚÄÇЩ»ùÓÚÀàµÄÓïÑÔ£¨±ÈÈçJava£©ÖУ¬¼Ì³Ð£¨inheritance»òextends£©ÌṩÁËÁ½¸öÓÐÓõķþÎñ¡£Ê×ÏÈ£¬ËüÊÇ´úÂëÖØÓõÄÒ»ÖÖÐÎʽ¡£Èç¹ûÒ»¸öеÄÀàÓëÒ»¸öÒÑ´æÔÚµÄÀà´ó²¿·ÖÏàËÆ£¬ÄÇôÄãÖ»Ðë¾ßÌå˵Ã÷Æ䲻ͬµã¼´¿É¡£Àà¼Ì³ÐµÄÁíÒ»¸öºÃ´¦ÊÇËü°üÀ¨ÁËÒ»Ì×ÀàÐÍϵͳµÄ¹æ·¶¡£ÓÉÓÚ³ÌÐòÔ±ÎÞÐë±àдÏÔʽÀàÐÍת»»µÄ´úÂ룬ËûÃǵŤ ......

JavascriptÍøÒ³¼ÆËãÆ÷

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>ÍøÒ³¼ÆËãÆ ......

javascriptµ÷ÓÃasp.netºǫ́µÄ¼¸ÖÖ·½·¨

1. javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ;
        2¡¢ÔÚǰ̨дһ¸öjsº¯Êý£¬ÄÚÈÝΪdocument.getElementById("btn1").click();
        3¡¢ÔÚǰ̨»òºǫ́µ÷ÓÃjsº¯Êý£¬¼¤·¢clickʼþ£¬µÈÓÚ·ÃÎʺǫ́c ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ