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

ÓÐ¹Ø 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¡£
console.log(typeof null);//object
ÕâʵÔÚÁîÈ˷ѽ⣬¼ÙÈç null ±íʾ¿ÕÖµ£¬ËüÔõô¿ÉÒÔÊǶÔÏ󣿼òµ¥Ëµ£¬ËüÊÇ JavaScript ×î³õ°æ±¾µÄ´íÎó£¬Õâ¸ö´íÎóÉõÖÁ±»Î¢ÈíµÄ JScript Ö±½Ó½èÓá£
3. NaN !== NaN
NaN£¬±íʾһ¸ö·ÇÊý×ÖµÄÖµ£¬È»¶øÎÊÌâÊÇ£¬NaN²»µÈÓÚÈκζ«Î÷£¬ÉõÖÁ²»µÈÓÚËü×Ô¼º¡£
console.log(NaN === NaN);//false
ÕâÏÔÈ»²»¶Ô£¬ÊÂʵÉÏ£¬Èç¹ûÒªÅжÏÒ»¸öֵȷʵÊÇ NaN£¬ÄãÐèÒªÓà isNaN() º¯Êý¡£
4. È«¾Ö±äÁ¿
¶ÔÈ«¾Ö±äÁ¿µÄÒÀÀµÒ»Ö±±»ÊÓΪ JavaScript ×µÄ²¿·Ö£¨ECMA µÄ JavaScript 5 ÒѾ­È¥µôÁËÈ«¾Ö±äÁ¿£¬Çë²ÎÔÄ ECMA ÍƳö JavaScript 5
- ÒëÕß×¢£©¡£¶Ô¼òµ¥µÄÒ³Ã棬ÕâÎÞËùν£¬µ«¸´ÔÓµÄÒ³Ã棬Èç¹û°üº¬´óÁ¿ JavaScript ½Å±¾£¬ÄãºÜÄÑÖªµÀij¸öÈ«¾Ö±äÁ¿ÊÇÔÚÄÄÀïÉùÃ÷µÄ£¬Èç¹û¼¸¸öÈ«¾Ö±äÁ¿²»Ð¡ÐÄÖØÃû£¬¾Í»áÒý·¢´íÎó¡£
5. ÄÇЩͳͳ±»Ì½²âΪ Mozilla User-Agent µÄä¯ÀÀÆ÷
±ØÐë³ÐÈÏ£¬ÊÂʵÉÏ£¬Õâ²»ÊÇ JavaScript  µÄ´í£¬ÊǸ÷¸öä¯ÀÀÆ÷ÓÐÒâΪ֮¡£±ÈÈ磬ÒÔÏÂÊÇÓà JavaScript ̽²â Safari ʱµÃµ½µÄ½á¹û£º
console.log(navigator.userAgent);
// Mozilla/5.0............
ÊÇ·ñ×¢Òâµ½ÆäÖеĵÚÒ»¸öµ¥´Ê Mozilla/5.0
£¬ÎªÊ²Ã´ Safari »á±»Ì½²âΪ
Mozilla£¬¾¡¹Ü Safari ºóÀ´ÒѾ­¾ÀÕýÕâÒ»ÎÊÌ⣬µ«ÈÔÈ»²»ÄܽâÊÍΪʲôËüÃÇÒªÕâÑùÎ󵼿ª·¢Õß¡£ÊÂʵÉÏ£¬Äã»á·¢ÏÖ£¬¾ø´ó¶àÊýä¯ÀÀÆ÷°ÑËûÃǵÄ
User Agent ÉèÖÃΪ Mozilla£¬´ð°¸Òª»Øµ½10ÄêÇ°£¬Õâ¸ü¶àÊÇÒ»ÖÖ²ßÂÔ¡£
User Agent ÊÇÒ»¶ÎÓÃÀ´±êʶµ±Ç°ä¯ÀÀÆ÷Éí·ÝµÄ×Ö·û´®£¬ÊÀ½çÉϵÚÒ»¸öä¯ÀÀÆ÷ Mosaic£¬ ÔøÕâÑù±êÖ¾×Ô¼º£º
Mosaic/0.9
ÕâºÜºÏÀí£¬Òò´Ëµ±


Ïà¹ØÎĵµ£º

ÓÃJavaScriptʵÏÖ¸ü¸´ÔӵĽ»»¥ [9]

Ò»¡¢Ê²Ã´ÊÇ¿ò¼Ü
¡¡¡¡¿ò¼ÜFrames×îÖ÷Òª¹¦ÓÃÊÇ"·Ö¸î"ÊÓ´°£¬Ê¹Ã¿¸ö"СÊÓ´°"ÄÜ
ÏÔʾ²»Í¬µÄHTM
LÎļþ£¬²»Í¬¿ò¼ÜÖ®¼ä¿ÉÒÔ»¥¶¯(interact)£¬Õâ¾ÍÊÇ˵²»Í¬¿ò¼ÜÖ®¼ä¿ÉÒÔ½»»»Ñ¶Ï¢Óë×ÊÁÏ¡£ÀýÈç:¼ÙÉèÄú¿ªÁËÁ½¸öframes£¬µÚÒ»¸öframe¿ÉÏÔ
ʾÊéµÄĿ¼£¬µÚ¶þ¸öframeÔòÏÔʾÕ½ڵľßÌåÄÚÈÝ¡£
¡¡¡¡¿ò¼Ü¿ÉÒÔ½«ÆÁÄ»·Ö¸î ......

javascript ¼¼ÇÉ

//×Ô´øµÄ´òÓ¡Ô¤ÀÀ WebBrowser.ExecWB(1,1) ´ò¿ª  
Web.ExecWB(2,1) ¹Ø±ÕÏÖÔÚËùÓеÄIE´°¿Ú£¬²¢´ò¿ªÒ»¸öд°¿Ú  
Web.ExecWB(4,1) ±£´æÍøÒ³  
Web.ExecWB(6,1) ´òÓ¡  
Web.ExecWB(7,1) ´òÓ¡Ô¤ÀÀ  
Web.ExecWB(8,1) ´òÓ¡Ò³ÃæÉèÖà 
Web.ExecWB(10,1) ²é¿´Ò ......

[ת]Top 10 Things that JavaScript Got Wrong

to make a note that I love JavaScript. This article is only meant for some fun, and for us to be aware of some its short-comings.
1. The Name. JavaScript is NOT Java
We'll start with a fun jab at the name choice. While it was originally called Mocha, and then LiveScript, it was later changed to J ......

javascriptÌí¼ÓнڵãµÄ·½·¨

//´´½¨Ò»¸öеÄÔªËؽڵ㣬ԪËØÃûʹÓÃsTagName¶¨Òå
oElementNode = document.createElementNode(sTagName);
//´´½¨Ò»¸öеĽڵ㣬½ÚµãÃûʹÓÃsTextValue¶¨Òå
oTextNode = document.createTextNode(sTextValue);
//ΪԪËظ³Ò»¸öеÄÊôÐÔ£¬ÊôÐÔÃûʹÓÃsName
oAttribute = document.createAttribute(sName);
//´´½¨Ò»¸öÐ嵀 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ