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

[·­Òë]High Performance JavaScript(023)

Data Formats  Êý¾Ý¸ñʽ
    When considering data transmission techniques, you must take into account several factors: feature set, compatibility, performance, and direction (to or from the server). When considering data formats, the only scale you need for comparison is speed.
    ÔÚ¿¼ÂÇÊý¾Ý´«Êä¼¼Êõʱ£¬Äã±ØÐ뿼ÂÇÕâЩÒòËØ£º¹¦Äܼ¯£¬¼æÈÝÐÔ£¬ÐÔÄÜ£¬ºÍ·½Ïò£¨·¢¸ø·þÎñÆ÷»òÕß´Ó·þÎñÆ÷½ÓÊÕ£©¡£ÔÚ¿¼ÂÇÊý¾Ý¸ñʽʱ£¬Î¨Ò»ÐèÒª±È½ÏµÄ³ß¶ÈµÄ¾ÍÊÇËÙ¶È¡£
    There isn't one data format that will always be better than the others. Depending on what data is being transferred and its intended use on the page, one might be faster to download, while another might be faster to parse. In this section, we create a widget for searching among users and implement it using each of the four major categories of data formats. This will require us to format a list of users on the server, pass it back to the browser, parse that list into a native JavaScript data structure, and search it for a given string. Each of the data formats will be compared based on the file size of the list, the speed of parsing it, and the ease with which it's formed on the server.
    ûÓÐÄÄÖÖÊý¾Ý¸ñʽ»áʼÖÕ±ÈÆäËû¸ñʽ¸üºÃ¡£¸ù¾Ý´«ËÍʲôÊý¾Ý¡¢ÓÃÓÚÒ³ÃæÉÏʲôĿµÄ£¬Ä³ÖÖ¸ñʽ¿ÉÄÜÏÂÔØ¸ü¿ì£¬ÁíÒ»ÖÖ¸ñʽ¿ÉÄܽâÎö¸ü¿ì¡£ÔÚ±¾½ÚÖУ¬ÎÒÃÇ´´½¨ÁËÒ»¸ö´°¿ÚС²¿¼þÓÃÓÚËÑË÷Óû§ÐÅÏ¢²¢ÓÃËÄÖÖÖ÷Á÷µÄÊý¾Ý¸ñʽʵÏÖËü¡£ÕâÒªÇóÎÒÃÇÔÚ·þÎñÆ÷¶Ë¸ñʽ»¯Ò»¸öÓû§ÁÐ±í£¬½«Ëü·µ»Ø¸øä¯ÀÀÆ÷£¬½«Áбí½âÎö³ÉJavaScriptÊý¾Ý¸ñʽ£¬²¢ËÑË÷ÌØ¶¨µÄ×Ö·û´®¡£Ã¿ÖÖÊý¾Ý¸ñʽ½«±È½ÏÁбíµÄÎļþ´óС£¬½âÎöËÙ¶È£¬ºÍ·þÎñÆ÷ÉϹ¹ÔìËüÃǵÄÄÑÒ׳̶ȡ£
XML
    When Ajax first became popular, XML was the data format of choice. It had many things going for it: extreme interoperability (with excellent support on both the server side and the client side), strict formatting, and easy validation. JSON hadn't been formalized yet as an interchange format, and almost every language used on servers had a library available for working with XML.
&


Ïà¹ØÎĵµ£º

[ת]¾«Í¨JSON (JavaScript Object Notation)


[ת×Ô]http://article.yeeyan.org/view/mouse4x/16540
JSON±»¹«ÈÏΪä¯ÀÀÆ÷ÖÐXMLµÄºó¼ÌÕߣ¬ËüµÄÄ¿±ê½ö½öÊdzÉΪһÖÖ¼òµ¥¡¢ÓÅÑŵÄÊý¾Ý¸ñʽ£¬ÒÔ·½±ãä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼äµÄÊý¾Ý½»»»¡£ÔÚÍê³ÉÕâÒ»¼òµ¥ÈÎÎñµÄ¹ý³ÌÖУ¬Ëü½«ÒýÁìÏÂÒ»´úÍòÎ¬Íø¡£
¶ÔÏó¼ò½é
¿´,Õâ¾ÍÊÇÒ»¸ö¶ÔÏó:
var myFirstObject ={};
¾¡¹Ü¿´ÆðÀ´Í¦¼òµ¥£¬È»¶øÄÇЩ» ......

javascript typeofÓ¦ÓÃ

typeof ÊÇJavaScriptµÄÔËËã·û
    ——·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®
   typeof[(] expression [)]  //typeofÓï·¨ÖеÄÔ²À¨ºÅÊÇ¿ÉÑ¡Ïî
  typeof ÔËËã·û@import url(../html-vss/msdnie4a.css);
typeof
ÔËËã·û°ÑÀàÐÍÐÅÏ¢µ±×÷×Ö·û´®·µ»Ø¡£typeof
·µ»ØÖµÓÐÁ ......

[·­Òë]High Performance JavaScript(017)

A Note on Benchmarking  ²âÊÔ»ù׼˵Ã÷
    Because a regex's performance can be wildly different depending on the text it's applied to, there's no straightforward way to benchmark regexes against each other. For the best result, you need to benchmark your regexes on test strings o ......

[·­Òë]High Performance JavaScript(019)

µÚÁùÕ  Responsive Interfaces  ÏìÓ¦½Ó¿Ú
    There's nothing more frustrating than clicking something on a web page and having nothing happen. This problem goes back to the origin of transactional web applications and resulted in the now-ubiquitous "please click only once" m ......

[·­Òë]High Performance JavaScript(022)

µÚÆßÕ  Ajax  Òì²½JavaScriptºÍXML
    Ajax is a cornerstone of high-performance JavaScript. It can be used to make a page load faster by delaying the download of large resources. It can prevent page loads altogether by allowing for data to be transferred between the client ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ