ÓÐ¹Ø JavaScript µÄ 10 ¼þÈÃÈ˷ѽâµÄÊÂÇé
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½ÓןÄÃûΪ LiveScript£¬×îºó²ÅÈ·¶¨ÃüÃûΪ JavaScript£¬¸ù¾ÝÀúÊ·¼Ç¼£¬Java µÄÃüÃûÓë Netscape ºÍ Sun Ö®¼äµÄºÏ×÷Óйأ¬×÷Ϊ½»»»Ìõ¼þ£¬Netscape ÔÚËûÃDZ¸ÊÜ»¶ÓµÄä¯ÀÀÆ÷Öд´½¨ÁË Java ÔËÐÐʱ¡£ÖµµÃÒ»ÌáµÄÊÇ£¬Õâ¸öÃû×ֵijǫ̈¼¸½üÒ»¸öÍæЦ£¬ÒªÖªµÀ£¬LiveScript ºÍ Java ÔÚ¿Í»§¶Ë½Å±¾·½Ãæ´æÔڵжԹØϵ¡£
²»¹ÜÔõô˵£¬ÈËÃǺóÀ´²»µÃ²»Ò»ÔÙ³ÎÇåµÄÒ»¼þʾÍÊÇ£¬JavaScript ºÍ Java ºÁÎÞ¹Øϵ¡£
2. Null ÊǸö¶ÔÏó£¿
¿´¿´Õâ¶Î´úÂ룬Ëü·µ»ØµÄÊÇ object¡£
ÕâʵÔÚÁîÈ˷ѽ⣬¼ÙÈç null ±íʾ¿ÕÖµ£¬ËüÔõô¿ÉÒÔÊǶÔÏ󣿼òµ¥Ëµ£¬ËüÊÇ JavaScript ×î³õ°æ±¾µÄ´íÎó£¬Õâ¸ö´íÎóÉõÖÁ±»Î¢ÈíµÄ JScript Ö±½Ó½èÓá£
3. NaN !== NaN
NaN£¬±íʾһ¸ö·ÇÊý×ÖµÄÖµ£¬È»¶øÎÊÌâÊÇ£¬NaN²»µÈÓÚÈκζ«Î÷£¬ÉõÖÁ²»µÈÓÚËü×Ô¼º¡£
ÕâÏÔÈ»²»¶Ô£¬ÊÂʵÉÏ£¬Èç¹ûÒªÅжÏÒ»¸öֵȷʵÊÇ NaN£¬ÄãÐèÒªÓà isNaN() º¯Êý¡£
4. È«¾Ö±äÁ¿
¶ÔÈ«¾Ö±äÁ¿µÄÒÀÀµÒ»Ö±±»ÊÓΪ JavaScript ×µÄ²¿·Ö£¨ECMA µÄ JavaScript 5 ÒѾȥµôÁËÈ«¾Ö±äÁ¿£¬Çë²ÎÔÄ ECMA ÍƳö JavaScript 5 - ÒëÕß×¢£©¡£¶Ô¼òµ¥µÄÒ³Ã棬ÕâÎÞËùν£¬µ«¸´ÔÓµÄÒ³Ã棬Èç¹û°üº¬´óÁ¿ JavaScript ½Å±¾£¬ÄãºÜÄÑÖªµÀij¸öÈ«¾Ö±äÁ¿ÊÇÔÚÄÄÀïÉùÃ÷µÄ£¬Èç¹û¼¸¸öÈ«¾Ö±äÁ¿²»Ð¡ÐÄÖØÃû£¬¾Í»áÒý·¢´íÎó¡£
5. ÄÇЩͳͳ±»Ì½²âΪ Mozilla User-Agent µÄä¯ÀÀÆ÷
±ØÐë³ÐÈÏ£¬ÊÂʵÉÏ£¬Õâ²»ÊÇ JavaScript µÄ´í£¬ÊǸ÷¸öä¯ÀÀÆ÷ÓÐÒâΪ֮¡£±ÈÈ磬ÒÔÏÂÊÇÓà JavaScript ̽²â Safari ʱµÃµ½µÄ½á¹û£º
ÊÇ·ñ×¢Òâµ½ÆäÖеĵÚÒ»¸öµ¥´Ê Mozilla/5.0£¬ÎªÊ²Ã´ Safari »á±»Ì½²âΪ Mozilla£¬¾¡¹Ü Safari ºóÀ´ÒѾ¾ÀÕýÕâÒ»ÎÊÌ⣬µ«ÈÔÈ»²»ÄܽâÊÍΪʲôËüÃÇÒªÕâÑùÎ󵼿ª·¢Õß¡£ÊÂʵÉÏ£¬Äã»á·¢ÏÖ£¬¾ø´ó¶àÊýä¯ÀÀÆ÷°ÑËûÃÇµÄ User Agent ÉèÖÃΪ Mozilla£¬´ð°¸Òª»Øµ½10ÄêÇ°£¬Õâ¸ü¶àÊÇÒ»ÖÖ²ßÂÔ¡£
User Agent ÊÇÒ»¶ÎÓÃÀ´±êʶµ±Ç°ä¯ÀÀÆ÷Éí·ÝµÄ×Ö·û´®£¬ÊÀ½çÉϵÚÒ»¸öä¯ÀÀÆ÷ Mosaic£¬ ÔøÕâÑù±êÖ¾×Ô¼º£º
ÕâºÜºÏÀí£¬Òò´Ëµ± Netscape ³öÀ´µÄʱºò£¬Ëü±£ÁôÁË Mosaic Õâ¸ö´«Í³£¬»¹ÔÚºóÃæÌí¼ÓÁËÒ»¸ö¼ÓÃÜ·½Ê½²¿·Ö¡£
µ½Ä¿Ç°ÎªÖ¹£¬Ò»Çа²ºÃ£¬Ö±µ½ IE3 ·¢²¼£¬µ± IE3 ·¢²¼µÄʱºò£¬Netscape ÕýÈçÈÕÖÐÌ죬ÄÇʱ£¬
Ïà¹ØÎĵµ£º
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM
API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript
ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½Óן ......
ÔÚ¶Ô³ÌÐò½øÐÐÐÔÄܲâÊÔʱÐèÒª¿¼Âǵ½²»Í¬¹æÄ£ÒÔ¼°²»Í¬Ëã·¨µÄЧÂʵIJ»Í¬
ÏÂÃæµÄÍøÒ³ÊÇÒ»¸ö¶ÔÅÅÐòËã·¨µÄÐÔÄܲâÊÔ£¬¹æÄ£¾ÍÊÇÊý×éµÄ³¤¶È£¬¶ø²âÊÔµÄÁ½¸öº¯Êý·Ö±ðÊÇÊÖ¶¯ÊµÏֵĿìËÙÅÅÐòËã·¨ºÍjavascriptÄÚÖõÄÅÅÐòº¯Êý¡£
<!DOCTYPE window PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- ......
JavaScript½âÎö¶ÁÈ¡XMLÎļþ£¬Ö÷Òª¾ÍÊǼÓÔز¢½âÎöXMLÎļþ£¬È»ºó¾Í¿ÉÒÔ²âÊÔ½âÎöµÄXMLÎļþµÄÄÚÈÝ£¬´òÓ¡Êä³öÀ´¡£
±àдÁËÒ»¸öJavaScriptµÄÀàÀ´ÊµÏÖ¶ÁÈ¡Ò»¸öXMLÎļþÖеÄÊý¾Ý£¬ÊµÏÖ´úÂëÈçÏÂËùʾ£º
<mce:script type="text/javascript"><!--
/**
* @author Shirdrn
*/
function XMLDoc(){}; // ¶¨ÒåÒ»¸öXM ......
Ä£·ÂjQuey£¬´´½¨¼¸¸ö°ü¹ü½ÚµãµÄ·½·¨£¬·¢ÏÖjQueryµÄ·½·¨ºÜµÍЧ°¡£¬ÏÂÒ»´ÎËûÓÖ¿ÉÒÔ˵Õ⼸¸ö·½·¨¿ÉÒÔÌáÉýÁ˶àÉÙ¶àÉÙÁË¡£ÔÀí»ù±¾ÊÇÕâÑù£¬Èç¹û´«ÈëµÄÊÇ×Ö·û´®£¬ÄÇôÈÃËüÃDZä³ÉÒ»¸öÔªËؽڵ㣬²»¹ýÕâÔªËؽڵãÒ²¿ÉÒÔÓÐÐí¶à²ã£¬ÔÚ×îÄÚ²ã°ÑÒª°ü¹üµÄÔªËطŽø¡£°Ñ×Ö·û´®±ä³ÉÔªËؽڵãµÄ·½·¨ÓÐÈçϼ¸¸ö¡£1£¬createElement£¬IE¿ÉÒÔÁ¬ÔªËØÊ ......