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

[·­Òë]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" message that accompanies most form submissions. A user's natural inclination is to repeat any action that doesn't result in an obvious change, and so ensuring responsiveness in web applications is an important performance concern.
    ûÓÐʲô±Èµã»÷Ò³ÃæÉϵĶ«Î÷ȴʲôҲû·¢Éú¸üÁîÈ˸е½´ìÕÛÁË¡£Õâ¸öÎÊÌâÓֻص½ÁËԭʼÍøÒ³½»»¥³ÌÐòºÍÏÖÔÚÒÑÎÞ´¦²»ÔÚµÄÌá½»±íµ¥Ê±µ¯³öµÄ“ÇëÎðÖظ´Ìá½»”ÏûÏ¢ÉÏÃæ¡£Óû§×ÔÈ»ÇãÏòÓÚÖظ´³¢ÊÔÕâЩ²»·¢ÉúÃ÷ÏԱ仯µÄ¶¯×÷£¬ËùÒÔÈ·±£ÍøÒ³Ó¦ÓóÌÐòµÄÏìÓ¦ËÙ¶ÈÒ²ÊÇÒ»¸öÖØÒªµÄÐÔÄܹØ×¢µã¡£
    Chapter 1 introduced the browser UI thread concept. As a recap, most browsers have a single process that is shared between JavaScript execution and user interface updates. Only one of these operations can be performed at a time, meaning that the user interface cannot respond to input while JavaScript code is executed and vice versa. The user interface effectively becomes "locked" when JavaScript is executing; managing how long your JavaScript takes to execute is important to the perceived performance of a web application.
    µÚÒ»½Ú½éÉÜÁËä¯ÀÀÆ÷UIÏ̸߳ÅÄî¡£×ܵÄÀ´Ëµ£¬´ó¶àÊýä¯ÀÀÆ÷ÓÐÒ»¸öµ¥¶ÀµÄ´¦Àí½ø³Ì£¬ËüÓÉÁ½¸öÈÎÎñËù¹²Ïí£ºJavaScriptÈÎÎñºÍÓû§½çÃæ¸üÐÂÈÎÎñ¡£Ã¿¸öʱ¿ÌÖ»ÓÐÆäÖеÄÒ»¸ö²Ù×÷µÃÒÔÖ´ÐУ¬Ò²¾ÍÊÇ˵µ±JavaScript´úÂëÔËÐÐʱÓû§½çÃæ²»ÄܶÔÊäÈë²úÉú·´Ó¦£¬·´Ö®ÒàÈ»¡£»òÕß˵£¬µ±JavaScriptÔËÐÐʱ£¬Óû§½çÃæ¾Í±»“Ëø¶¨”ÁË¡£¹ÜÀíºÃJavaScriptÔËÐÐʱ¼ä¶ÔÍøÒ³Ó¦ÓõÄÐÔÄܺÜÖØÒª¡£
The Browser UI Thread  ä¯ÀÀÆ÷UIÏß³Ì
    The process shared by JavaScript and user interface updates is frequently referred to as the browser UI thread (though the term "thread" is not necessarily accurate for all browsers). The UI thread works on a sim


Ïà¹ØÎĵµ£º

JavaScriptʼþ´óÈ«

JavaScriptʼþ´óÈ«
 
 
click() ¶ÔÏó.click() ʹ¶ÔÏó±»µã»÷¡£
closed ¶ÔÏó.closed ¶ÔÏó´°¿ÚÊÇ·ñÒѹرÕtrue/false
clearTimeout(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetTimeout¶ÔÏó
clearInterval(¶ÔÏó) Çå³ýÒÑÉèÖõÄsetInterval¶ÔÏó
confirm("ÌáʾÐÅÏ¢") µ¯³öÈ·ÈÏ¿ò£¬È·¶¨·µ»ØtrueÈ¡Ïû·µ»Øfalse
cursor:Ñùʽ ¸ü¸ÄÊó±êÑùÊ ......

JavaScript»ù´¡ÖªÊ¶2

ÍæPHP¡¢Delphi¡¢Java»ù±¾É϶¼ÓжÔÏó£¬Ï°¹ßÕâÖÖ˼·ºóÉÏÊÖÈκÎÓïÑÔ¶¼Ïë¿¿OO˼·£¬Õâ¾ø²»ÊÇÔÚ¸Ïʱ÷Ö£¬¶øÊÇ°ÑÏà¹Ø´úÂë½øÐÐÄÚ¾ÛµÄÈ·¿ÉÒÔÌå»áµ½Î¬»¤µÄ·½±ã£¡
ÔÚJavaScriptÖÐÈçºÎ´´½¨¶ÔÏó£¿
JavaScriptÊÇ»ùÓÚ¶ÔÏóµÄ£¡ËüÒ²ÊÇÒÔObjectΪ¸ùÀ࣬ÆäËüÀà¼Ì³ÐÖ®¡£ÔÚ¸ùÀàÌṩÁ˼¸¸ö·½·¨¡£¹©¼Ì³ÐÀàʹÓã¡
ÒÔÏÂÊÇ´´½¨¶ÔÏóµÄÀý×Ó£º
funct ......

Javascript±Õ°ü(Closure)

ClosureÖÐÎÄ·­ÒëΪ±Õ°ü.×ÖÃæÉÏÀ´Àí½â¾ÍÊÇ"·â±ÕµÄ°ü".(ÕâÊÇÒ»¾ä·Ï»°)
±Õ°üÊÇʲô?
ÊéÃæ½âÊÍΪ:
Ëùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
ÎÒÈÏΪ±Õ°ü¾ÍÊÇÄܹ»¶Á/дº¯ÊýÄÚ²¿µÄijЩ±äÁ¿µÄ×Óº¯Êý,²¢½«ÕâЩ±äÁ¿±£´æ ......

javascript typeofÓ¦ÓÃ

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

JavaScript»ù´¡ÖªÊ¶3

Òþ²Ø³ÉÔ±±äÁ¿
ÔÚº¯ÊýÌåÄÚ¶¨ÒåµÄ±äÁ¿Îª¾Ö²¿±äÁ¿£¬À뿪º¯Êý¾Í¹ÒµôÁË
ÔÚº¯ÊýÌåÄÚʹÓÃthis.³ÉÔ±±äÁ¿Ãû£¬ÔòΪwindow¶ÔÏ󼶱äÁ¿£¬¼´È«¾Ö±äÁ¿
¹ÊÐèÒªÕâÑùÒþ²Ø³ÉÔ±±äÁ¿£¬ÏòÍâÖ»±©Â¶get¡¢setº¯Êý
function testClass(name){
var _firstname=name;
return {
getname : function() {
return _fir ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ