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

JavascriptµÄÔ­ÐͶÔÏóºÍprototypeÊôÐÔ

     JavascriptÖеļ̳лúÖÆÊÇËùνµÄÔ­ÐͶÔÏó¼Ì³Ð£¬Í¨¹ýÊôÐÔ·ÃÎÊ»úÖƵÄÌØÊâÐÔÀ´ÊµÏּ̳еġ£Ö®Ç°ÎÒÒ»Ö±ÒÔΪËùÓжÔÏóµÄÔ­ÐͶÔÏó¾ÍÊÇprototypeËùÖ¸µÄÄǸö¶ÔÏ󡣺óÀ´ÔÚ¿´javascriptÉè¼ÆģʽµÄʱºò·¢ÏÖ×÷Õß×¢ÖÐÓÐÒ»¾ä»°ÓëÎÒ֮ǰµÄÀí½â²»Í¬£¬Ëû˵“ÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öÔ­ÐͶÔÏ󣬵«Õâ²¢²»Òâζ×Åÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öprototypeÊôÐÔ”¡£¿´ÍêÎÒ¾ÍÓеãÃÔãÁË£¬¾ö¶¨³¹µ×°ÑÕâ¸öËÀÈ˵ÄÔ­Ðͼ̳иã¸ãÇå³þ¡£È»ºó·­ÁËЩÎÄÕºÍÊé¼®£¬×îºóÖÕÓÚÔÚjavascriptȨÍþÖ¸ÄϵÚÎå°æÖÐÕÒµ½Á˸öÈË ÈÏΪ±È½ÏȨÍþµÄ½âÊÍ¡£¹ØÓÚÔ­ÐÍÁ´ºÍÊôÐÔ·ÃÎÊ»úÖÆÎҾͲ»ÔÙ²ûÊöÁË£¬Õâ·½Ãæ¿ÉÒÔ¿´¿´RockyµÄÎÄÕ дµÄÂùÇå³þµÄ http://blog.csdn.net/rocky_j2ee/archive/2009/03/21/4012385.aspx
ÄÇÎÒÃÇÏÈ´Ó´´½¨¶ÔÏó˵Æð£¬ÓÃnew²Ù×÷·û´´½¨¶ÔÏóµÄʱºòjavascript»á×ö3¼þÊ£º
Ê×ÏÈÊÇ´´½¨Ò»¸ö¿Õ¶ÔÏó£¨empty object£©£¬
È»ºó¶ÔÕâ¸ö¿Õ¶ÔÏóµÄÔ­ÐͶÔÏó½øÐи³Öµ£¬
×îºó°ÑÕâ¸ö¿Õ¶ÔÏó¸³Öµ¸ø¹¹Ô캯ÊýµÄthisÊôÐÔÇÒÔËÐÐÕâ¸ö¹¹Ô캯Êý¡£
function Person(name) {
    this.name = name;
}
var  p = new Person();
 Ï൱ÓÚÒÔϲ½Ö裺
1. Var p = {};
2. p.[[prototype]] = Person.prototype
  //ÕâÒ»²½ÊÇα´úÂ룬ʵ¼ÊÉÏÒ»¸ö¶ÔÏóµÄÔ­ÐͶÔÏóÊDz»ÄÜͨ¹ý´úÂëÀ´·ÃÎʵģ¬
                                                              //ÕâÀïÖ»ÊÇΪÁË˵Ã÷´´½¨¶ÔÏóµÄ²½Öè
3. p.methodName = Person
;                  //ÕâÑùµÄ»°PersonµÄthis¾Í»áÖ¸Ïòp
   p.methodName();
Èç¹ûÄã¶ÔµÚ¶þ²½²»ÊǺÜÃ÷°×£¬ÄÇôÏÈ°Ñ´úÂë·ÅÒ»·Å£¬½ÓÏÂÀ´ÎÒ»áÏêϸ½âÊÍϵڶþ²½Ô­ÐͶÔÏóµÄ¸³Öµ£¨»òÕß˵¹¹Ô캯ÊýºÍÔ­ÐͶÔÏóµÄ¹Øϵ£©:ÉÏÃæÎÒÌáµ½¹ýÔÚ´´½¨ÍêÒ»¸ö¿Õ¶ÔÏóºó£¬»á³õʼ»¯Õâ¸ö¿Õ¶ÔÏóµÄÔ­ÐͶÔÏó£¬javascript»á°Ñ¹¹Ô캯ÊýµÄÒ»¸ö½Ð×öprototypeµÄÊôÐÔËùÖ¸ÏòµÄ¶ÔÏó¸³Öµ¸øµ±Ç°¿Õ¶ÔÏóµÄÔ­ÐͶÔÏó¡£ËùÓеÄfunction¶¼ÓÐÒ»¸öprototypeÊôÐÔ£¬µ±Ò»¸öfunction±»¶¨ÒåÖ®ºóÕâ¸öÊôÐԻᱻ×Ô¶¯µÄ´´½¨ºÍ³õʼ»¯¡£Ò»¸öfunction µÄprototypeÊôÐԵijõʼֵÊÇÒ»¸ö¶ÔÏó£¨an object£©£¬Õâ¸ö¶ÔÏóÖ»ÓÐÒ»¸öÊôÐÔ½Ð×öconstructor£¬¶øÕâ¸öconstructor µÄÖµ¾ÍÊǵ±Ç°Õâ¸öº¯Êý£¨»òÕß½


Ïà¹ØÎĵµ£º

javascriptÖÐevent.keycode

javascriptÖÐevent.keycode
 keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space ......

JavaScript ¹¹Ô캯Êý myhere

/**
* JavaScript ÊÇÃæÏò¶ÔÏóµÄÓïÑÔ£¬µ«ÊÇËûµÄÃæÏò¶ÔÏó²»ÊÇ»ùÓÚÀàµÄ£¬ÊÇ»ùÓÚÔ­Ð͵Ä;
* µ«ÊÇËûµÄһЩÌØÐÔ(º¯ÊýÊÇÊý¾Ý)£¬Ê¹µÃËü¿ÉÒÔÄ£Äâ»ùÓÚÀàµÄÃæÏò¶ÔÏ󣬵«ÊÇ JavaScript ²¢²»Ö§³ÖºÍ Java Ò»ÑùµÄÀ࣬
* Òò´Ë JavaScript ÖеÄ"Àà"¿ÉÒÔ³Æ×÷"αÀà"
*/
//
/**
* ¹¹Ô캯Êý: js ÖÐÓÃÀ´ºÍ new ÔËËã·ûÒ»ÆðʹÓõĺ¯Êý³Æ× ......

Javascript µÄ´Ê·¨×÷ÓÃÓò¡¢µ÷ÓöÔÏóºÍ±Õ°ü

×÷ÓÃÓò Scope
Javascript Öеĺ¯ÊýÊôÓÚ´Ê·¨×÷ÓÃÓò£¬Ò²¾ÍÊÇ˵º¯ÊýÔÚËü±»¶¨ÒåʱµÄ×÷ÓÃÓòÖÐÔËÐжø²»ÊÇÔÚ±»Ö´ÐÐʱµÄ×÷ÓÃÓòÄÚÔËÐС£ÕâÊÇϬţÊéÉϵÄ˵·¨¡£µ«“¶¨Òåʱ”ºÍ“Ö´ÐУ¨±»µ÷Óã©Ê±”ÕâÁ½¸ö¶«Î÷ÓÐЩÈ˸㲻Çå³þ¡£¼òµ¥À´Ëµ£¬Ò»¸öº¯ÊýAÔÚ“¶¨Òåʱ”¾ÍÊÇ function A(){} Õâ¸öÓï¾äÖ´ÐеÄʱºò¾Í ......

javascript ÅжϷ½·¨ÊÇ·ñ´æÔÚ

µÚÒ»ÖÖ·½·¨ÈçÏÂ
if (typeof beforeReject != 'undefined' && beforeReject instanceof Function) {
beforeReject(nextStep);
}
µÚ¶þÖÖ·½·¨ÈçÏÂ
if (¶ÔÏóÃû.·½·¨Ãû)
{
//·½·¨´æÔÚ
¶ÔÏóÃû.·½·¨Ãû();
}
µÚÈýÖÖ·½·¨£º
if(typeof(nl.onBlue)=="function")
{
//´æÔÚ
} ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ