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

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


http://blog.csdn.net/mouyong/archive/2009/12/07/4959741.aspx
µÚ4Õ  º¯Êý
JavaScriptÖÐ×îºÃµÄÌØÐÔ¾ÍÊÇËü¶Ôº¯ÊýµÄʵÏÖ¡£Ëü¼¸ºõÎÞËù²»ÄÜ¡£µ«ÊÇ£¬Ïë±ØÄãÒ²ÄÜÔ¤Áϵ½£¬º¯ÊýÔÚJavaScriptÀïÒ²²¢·ÇÍòÄÜÒ©¡£
º¯Êý°üº¬Ò»×éÓï¾ä£¬ËüÃÇÊÇJavaScriptµÄ»ù´¡Ä£¿éµ¥Ôª£¬ÓÃÓÚ´úÂ븴Óá¢ÐÅÏ¢Òþ²ØºÍ×éºÏµ÷Ó᣺¯ÊýÓÃÓÚÖ¸¶¨¶ÔÏóµÄÐÐΪ¡£Ò»°ãÀ´Ëµ£¬Ëùν±à³Ì¾ÍÊǽ«Ò»×éÐèÇó·Ö½â³ÉÒ»×麯ÊýÓëÊý¾Ý½á¹¹µÄ¼¼ÄÜ¡£
4.1   º¯Êý¶ÔÏó
ÔÚJavaScriptÖк¯Êý¾ÍÊǶÔÏ󡣶ÔÏóÊÇ“Ãû£ºÖµ”¶ÔµÄ¼¯ºÏ²¢ÓµÓÐÒ»¸öÁ¬µ½Ô­ÐͶÔÏóµÄÒþ²ØÁ¬½Ó¡£¶ÔÏó¶¨Òå²úÉúµÄ¶ÔÏóÁ¬½Óµ½Object.prototype¡£º¯Êý¶ÔÏóÁ¬½Óµ½Function.prototype(¸ÃÔ­ÐͶÔÏó±¾ÉíÁ¬½Óµ½Object.prototype)¡£Ã¿¸öº¯ÊýÔÚ´´½¨Ê±¸½ÓÐÁ½¸ö¸½¼ÓµÄÒþ²ØÊôÐÔ£ºº¯ÊýµÄÉÏÏÂÎĺÍʵÏÖº¯ÊýÐÐΪµÄ´úÂ루JavaScript´´½¨Ò»¸öº¯Êý¶ÔÏóʱ£¬»á¸ø¸Ã¶ÔÏóÉèÖÃÒ»¸ö“µ÷ÓÔÊôÐÔ¡£µ±JavaScriptµ÷ÓÃÒ»¸öº¯Êýʱ£¬¿ÉÀí½âΪִÐÐÁ˴˺¯ÊýµÄ“µ÷ÓÔÊôÐÔ¡£¾ßÌå²ÎÔÄECMAScript¹æ·¶µÄ13.2 Creating Function Object£©¡£
ÿ¸öº¯Êý¶ÔÏóÔÚ´´½¨Ê±Ò²Ëæ´øÓÐÒ»¸öprototypeÊôÐÔ¡£ËüµÄÖµÊÇÒ»¸öÓµÓÐconstructorÊôÐÔÇÒÖµ¼´Îª¸Ãº¯ÊýµÄ¶ÔÏó¡£ÕâºÍÒþ²ØÁ¬½Óµ½Function.prototypeÍêÈ«²»Í¬¡£Õâ¸öÁîÈ˷ѽâµÄ¹¹Ôì¹ý³ÌµÄÒâÒ彫»áÔÚϸöÕ½ÚÖнÒʾ¡£
ÒòΪº¯ÊýÊǶÔÏó£¬ËùÒÔËüÃÇ¿ÉÒÔÏñÈκÎÆäËûµÄÖµÒ»Ñù±»Ê¹Ó᣺¯Êý¿ÉÒÔ´æ·ÅÔÚ±äÁ¿£¬¶ÔÏóºÍÊý×éÖУ¬º¯Êý¿ÉÒÔ±»µ±×÷²ÎÊý´«µÝ¸øÆäËûº¯Êý£¬º¯ÊýÒ²¿ÉÒÔÔÙ·µ»Øº¯Êý¡£¶øÇÒ£¬ÒòΪº¯ÊýÊǶÔÏó£¬ËùÒÔº¯Êý¿ÉÒÔÓµÓз½·¨¡£
4.2   º¯Êý¶¨Òå
º¯Êý¶ÔÏó¿ÉÒÔͨ¹ýº¯Êý¶¨ÒåÀ´´´½¨£º
//´´½¨Ò»¸öÃûΪaddµÄ±äÁ¿£¬²¢ÓÃÀ´°ÑÁ½¸öÊý×ÖÏà¼ÓµÄº¯Êý¸³Öµ¸øËü¡£
var add=function(a,b){
         return a+b;
};
º¯Êý¶¨Òå°üÀ¨Ëĸö²¿·Ö¡£µÚÒ»¸ö²¿·ÖÊǹؼü×Öfunction
µÚ¶þ²¿·ÖÊǺ¯ÊýÃû£¬Ëü¿ÉÒÔ±»Ê¡ÂÔ¡£º¯Êý¿ÉÒÔÓÃËüµÄÃû×ÖÀ´µÝ¹éµØµ÷ÓÃ×Ô¼º¡£´ËÃû×ÖÒ²Äܱ»µ÷ÊÔÆ÷ºÍ¿ª·¢¹¤¾ßÀ´Ê¶±ðº¯Êý¡£Èç¹ûûÓиøº¯ÊýÃüÃû£¬±ÈÈçÉÏÃæÕâ¸öÀý×Ó£¬Ëü»á±»ÈÏΪÊÇÄäÃûº¯Êý¡£
º¯ÊýµÄµÚÈý²¿·ÖÊÇ°üΧÔÚÔ²À¨ºÅÖеÄÒ»×é²ÎÊý¡£ÆäÖÐÿ¸ö²ÎÊýÓöººÅ·Ö¸ô¡£ÕâЩÃû³Æ½«±»¶¨ÒåΪº¯ÊýÖеıäÁ¿¡£ËüÃDz»ÏñÆÕͨµÄ±äÁ¿ÄÇÑù½«±»³õʼ»¯Îªundefined£¬¶øÊÇÔڸú¯Êý±»µ÷ÓÃʱ³õʼ»¯ÎªÊµ¼ÊÌṩµÄ²ÎÊýµÄÖµ¡£
µÚËIJ¿·ÖÊÇ°üΧÔÚ»¨À¨ºÅÖеÄÒ»×éÓï¾ä¡£ÕâЩÓï¾äÊǺ¯ÊýµÄÖ÷Ìå¡£ËüÃÇÔÚº¯Êý±»µ÷ÓÃʱִÐС£


Ïà¹ØÎĵµ£º

Îò͸JavaScript(תÌù)

ÄѵÃÒ»¼ûµÄºÃÎÄ£¬¶ÔÓµÓÐOOP»ù´¡£¬ÓÖÏë¿ìËÙѧϰJavaScriptµÄ³ÌÐòÔ±¶øÑÔ£¬ÕâƪÎÄÕÂÈÃÈËõ®õ­¹à¶¥£¬Ã©Èû¶Ù¿ª¡£ÈçͬÐéÖñ±»ÎÞÑÄ×Ó¹àÊäÁË70ÄêµÄÄÚÁ¦Ò»°ã£¬¿ÉÒÔ˵һÎĵãÆÆJS°¡£¡
Ô­Îijö´¦£ºÎò͸JavaScript
Òý×Ó
    ±à³ÌÊÀ½çÀïÖ»´æÔÚÁ½ÖÖ»ù±¾ÔªËØ£¬Ò»¸öÊÇÊý¾Ý£¬Ò»¸öÊÇ´úÂë¡£±à³ÌÊÀ½ç¾ÍÊÇÔÚÊý¾ÝºÍ´úÂëǧ˿ÍòÂƵ ......

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

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

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

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

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

µÚ6ÕÂ
 
Êý×é
Êý×éÊÇÒ»¶ÎÏßÐÔ·ÖÅäµÄÄڴ棬Ëüͨ
¹ýÕûÊýÈ¥¼ÆËãÆ«ÒƲ¢·ÃÎÊÆäÖеÄÔªËØ¡£Êý×é¿ÉÒÔÊǺܿìµÄÊý¾Ý½á¹¹¡£²»ÐÒµÄÊÇ£¬
JavaScript
µÄÊý×é²»ÊÇÕâÑùµÄ¡£ËüÌṩÁËÒ»ÖÖÓµÓÐÀàËÆÊý×éÌØÐԵĶÔÏó¡£Ëü°ÑÊý×éµÄϱêת±ä³É×Ö·û´®£¬ÓÃÆä×÷ΪÊô
ÐÔ¡£ËüÃ÷ÏԵرÈÒ»¸öÕæÕýµÄÊý×éÂý£¬µ«Ëü¿ÉÒÔ¸ü·½±ãµØʹÓá£ÊôÐԵļìË÷ºÍ¸ü ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ