JavaScript¾«´â¶ÁÊé±Ê¼Ç(5)
http://blog.csdn.net/mouyong/archive/2010/01/10/5169396.aspx
µÚ5Õ ¼Ì³Ð
ÔÚÄÇЩ»ùÓÚÀàµÄÓïÑÔ£¨±ÈÈçJava£©ÖУ¬¼Ì³Ð£¨inheritance»òextends£©ÌṩÁËÁ½¸öÓÐÓõķþÎñ¡£Ê×ÏÈ£¬ËüÊÇ´úÂëÖØÓõÄÒ»ÖÖÐÎʽ¡£Èç¹ûÒ»¸öеÄÀàÓëÒ»¸öÒÑ´æÔÚµÄÀà´ó²¿·ÖÏàËÆ£¬ÄÇôÄãÖ»Ðë¾ßÌå˵Ã÷Æ䲻ͬµã¼´¿É¡£Àà¼Ì³ÐµÄÁíÒ»¸öºÃ´¦ÊÇËü°üÀ¨ÁËÒ»Ì×ÀàÐÍϵͳµÄ¹æ·¶¡£ÓÉÓÚ³ÌÐòÔ±ÎÞÐë±àдÏÔʽÀàÐÍת»»µÄ´úÂ룬ËûÃǵŤ×÷Á¿½«´ó´ó¼õÇᣬÕâÊÇÒ»¼þºÜºÃµÄÊÂÇ飬ÒòΪÀàÐÍת»»Ê±»á¶ªÊ§ÀàÐÍϵͳÔÚ°²È«Éϵĺô¦¡£
JavaScriptÊÇÒ»ÃÅÈõÀàÐÍÓïÑÔ£¬´Ó²»ÐèÒªÀàÐÍת»»¡£¶ÔÏóµÄÆðÔ´ÊÇÎ޹ؽôÒªµÄ¡£¶ÔÓÚÒ»¸ö¶ÔÏóÀ´ËµÖØÒªµÄÊÇËüÄÜ×öʲô£¬¶ø²»ÊÇËü´ÓÄÄÀïÀ´¡£
JavaScriptÌṩÁËÒ»Ì׸üΪ·á¸»µÄ´úÂëÖØÓÃģʽ¡£Ëü¿ÉÒÔÄ£ÄâÄÇЩ»ùÓÚÀàµÄģʽ£¬Í¬Ê±ËüÒ²¿ÉÒÔÖ§³ÖÆäËû¸ü¾ß±íÏÖÁ¦µÄģʽ¡£ÔÚJavaScriptÖпÉÄܵļ̳ÐģʽÓкܶࡣÔÚ±¾ÕÂÖУ¬ÎÒÃǽ«Ñо¿¼¸ÖÖ×îΪֱ½ÓµÄģʽ¡£µ±È»»¹Óиü¶à¸üΪ¸´ÔӵĽṹ£¬µ«±£³ÖËüµÄ¼òµ¥Í¨³£ÊÇ×îºÃµÄ¡£
ÔÚ»ùÓÚÀàµÄÓïÑÔÖУ¬¶ÔÏó ÊÇÀàʵÀý£¬²¢ÇÒÀà¿ÉÒÔ´ÓÁíÒ»¸öÀà¼Ì³Ð¡£JavaScriptÊÇÒ»ÃÅ»ùÓÚÔÐ͵ÄÓïÑÔ£¬ÕâÒâζ×ŶÔÏóÖ±½Ó´ÓÆäËû¶ÔÏó¼Ì³Ð¡£
5.1 αÀà
µ±Ò»¸öº¯Êý¶ÔÏó±»´´½¨Ê±£¬Function¹¹ÔìÆ÷²úÉúµÄº¯Êý¶ÔÏó»áÔËÐÐÀàËÆÕâÑùµÄһЩ´úÂ룺
this.prototype={constructor:this};
к¯Êý¶ÔÏ󱻸³ÓèÒ»¸öprototypeÊôÐÔ£¬ÆäÖµÊÇ°üº¬Ò»¸öconstructorÊôÐÔÇÒÊôÐÔֵΪ¸Ãк¯Êý¶ÔÏ󡣸Ãprototype¶ÔÏóÊÇ´æ·Å¼Ì³ÐÌØÕ÷µÄµØ·½¡£ÒòΪJavaScriptÓïÑÔûÓÐÌṩһÖÖ·½·¨È¥È·¶¨Äĸöº¯ÊýÊÇ´òËãÓÃÀ´×÷¹¹ÔìÆ÷µÄ£¬ËùÒÔÿ¸öº¯Êý¶¼»áµÃµ½Ò»¸öprototype¶ÔÏó¡£constructorÊôÐÔûʲôÓá£ÖØÒªµÄÊÇprototype¶ÔÏó¡£
µ±²ÉÓù¹ÔìÆ÷µ÷ÓÃģʽ£¬¼´Ê¹ÓÃnewǰ׺ȥµ÷ÓÃÒ»¸öº¯Êýʱ£¬Õ⽫Ð޸ĺ¯ÊýÖ´Ðеķ½Ê½¡£Èç¹ûnewÔËËã·ûÊÇÒ»¸ö·½·¨¶ø²»ÊÇÒ»¸öÔËËã·û£¬Ëü¿ÉÄÜ»áÏñÕâÑùÖ´ÐУº
Function.method(‘new’,function(){
//´´½¨Ò»¸öжÔÏó£¬Ëü¼Ì³Ð×Ô¹¹ÔìÆ÷º¯ÊýµÄÔÐͶÔÏó¡£
var that=Object.beget(this.prototype);
//µ÷Óù¹ÔìÆ÷º¯Êý£¬°ó¶¨thisµ½Ð¶ÔÏóÉÏ¡£
var other = this.apply(that,arguments);
//Èç¹ûËüµÄ·µ»ØÖµ²»ÊÇÒ»¸ö¶ÔÏ󣬾ͷµ»Ø¸ÃжÔÏó
&nbs
Ïà¹ØÎĵµ£º
ʹÓÃJavaScript¿ÉÒÔ½«Óû§µ¼ÏòÒ»¸öÌض¨µÄµØÖ·£¬²¢ÇÒ²»Í¬µÄ·½·¨»á¶Ôä¯ÀÀÆ÷µÄÀúÊ·¼Ç¼Óв»Í¬µÄÓ°Ïì¡£
ʵÀýJavaScript´úÂë
±¾Àý¶¨ÒåÁËÁ½¸öJavaScriptº¯Êý£¬¹¦Äܶ¼ÊÇÖض¨Ïòµ½Ê×Ò³£¬µ«ÊǵÚÒ»¸öº¯Êý²ÉÓõÄÊÇÖ±½Ó¸øhref¸³ÖµµÄ·½Ê½£¬µÚ¶þ¸öʹÓõÄÊÇreplace·½·¨¡£¾ßÌåÇë¿´ÏÂÃæµÄ´úÂ룺
<script type="text/javascript">
f ......
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½ÓןÄÃûÎ ......
Èç¹ûÄãÏë¼ÓÎÒΪºÃÓÑ£ºÇëµã»÷ÒÔÏÂÁ´½Óhttp://hi.csdn.net/invite.php?u=8943&c=759c7fc189ea23c1
µÚ1ÕÂ
¾«»ª
JavaScript
µÄÌØÐÔÖÐÓÐÒ»²¿
·ÖÌØÐÔ´øÀ´µÄÂé·³Ô¶Ô¶³¬³öËüÃǵļÛÖµ¡£ÆäÖУ¬Ò»Ð©ÌØÐÔÊÇÒòΪ¹æ·¶ºÜ²»ÍêÉÆ£¬´Ó¶ø¿ÉÄܵ¼Ö¿ÉÒÆÖ²ÐÔµÄÎÊÌ⣻һЩÌØÐԻᵼÖÂÉú³ÉÄÑÒÔÀí½âºÍÐ޸ĵĴúÂ룻һЩÌØ
ÐÔ´ ......
µÚ8ÕÂ
·½·¨
JavaScript
°üº¬ÁËÉÙÁ¿¿ÉÓÃ
ÔÚ±ê×¼ÀàÐÍÉϵıê×¼·½·¨¡£
Array
array.concat(item…)
concat
·½·¨·µ»ØÒ»¸öÐÂÊý×飬Ëü
°üº¬
array
µÄdz¸´ÖÆ
(shallow copy)
²¢½«
1
¸ö»ò¶à¸ö²ÎÊý
item
¸½¼ÓÔÚÆäºó¡£Èç¹û²ÎÊý
item
ÊÇÒ»¸öÊý×飬ÄÇôËüµÄÿ¸öÔªËػᱻ·Ö±ðÌí¼Ó¡£´ËÍ⣬Çë²Î¼û±¾Õºóà ......
http://blog.csdn.net/mouyong/archive/2009/10/02/4626852.aspx
Èç¹ûÄãÏë¼ÓÔ×÷ÕßΪºÃÓÑ£ºÇëµã»÷ÒÔÏÂÁ´½Óhttp://hi.csdn.net/invite.php?u=8943&c=759c7fc189ea23c1
µÚ1Õ ¾«»ª
JavaScriptµÄÌØÐÔÖÐÓÐÒ»²¿·ÖÌØÐÔ´øÀ´µÄÂé·³Ô¶Ô¶³¬³öËüÃǵļÛÖµ¡£ÆäÖУ¬Ò»Ð©ÌØÐÔÊÇÒòΪ¹æ·¶ºÜ²»ÍêÉÆ£¬´Ó¶ø¿ÉÄܵ¼Ö¿ÉÒÆ ......