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

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

µÚ¶þÕ  Data Access  Êý¾Ý·ÃÎÊ
    One of the classic computer science problems is determining where data should be stored for optimal reading and writing. Where data is stored is related to how quickly it can be retrieved during code execution. This problem in JavaScript is somewhat simplified because of the small number of options for data storage. Similar to other languages, though, where data is stored can greatly affect how quickly it can be accessed later. There are four basic places from which data can be accessed in JavaScript:
    ¾­µä¼ÆËã»ú¿ÆÑ§µÄÒ»¸öÎÊÌâÊÇÈ·¶¨Êý¾ÝÓ¦µ±´æ·ÅÔÚʲôµØ·½£¬ÒÔʵÏÖ×î¼ÑµÄ¶ÁдЧÂÊ¡£Êý¾Ý´æ´¢ÔÚÄÄÀ¹ØÏµµ½´úÂëÔËÐÐÆÚ¼äÊý¾Ý±»¼ìË÷µ½µÄËÙ¶È¡£ÔÚJavaScriptÖУ¬´ËÎÊÌâÏà¶Ô¼òµ¥£¬ÒòΪÊý¾Ý´æ´¢Ö»ÓÐÉÙÁ¿·½Ê½¿É¹©Ñ¡Ôñ¡£ÕýÈçÆäËûÓïÑÔÄÇÑù£¬Êý¾Ý´æ´¢Î»ÖùØÏµµ½·ÃÎÊËÙ¶È¡£ÔÚJavaScriptÖÐÓÐËÄÖÖ»ù±¾µÄÊý¾Ý·ÃÎÊλÖãº
Literal values  Ö±½ÓÁ¿
Any value that represents just itself and isn't stored in a particular location. JavaScript can represent strings, numbers, Booleans, objects, arrays, functions, regular expressions, and the special values null and undefined as literals.
Ö±½ÓÁ¿½ö½ö´ú±í×Ô¼º£¬¶ø²»´æ´¢ÓÚÌØ¶¨Î»ÖᣠJavaScriptµÄÖ±½ÓÁ¿°üÀ¨£º×Ö·û´®£¬Êý×Ö£¬²¼¶ûÖµ£¬¶ÔÏó£¬Êý×飬º¯Êý£¬ÕýÔò±í´ïʽ£¬¾ßÓÐÌØÊâÒâÒåµÄ¿ÕÖµ£¬ÒÔ¼°Î´¶¨Òå¡£
Variables  ±äÁ¿
Any developer-defined location for storing data created by using the var keyword.
¿ª·¢ÈËԱʹÓÃvar¹Ø¼ü×Ö´´½¨ÓÃÓÚ´æ´¢Êý¾ÝÖµ¡£
Array items  Êý×éÏî
A numerically indexed location within a JavaScript Array object.
¾ßÓÐÊý×ÖË÷Òý£¬´æ´¢Ò»¸öJavaScriptÊý×é¶ÔÏó¡£
Object members  ¶ÔÏó³ÉÔ±
A string-indexed location within a JavaScript object.
¾ßÓÐ×Ö·û´®Ë÷Òý£¬´æ´¢Ò»¸öJavaScript¶ÔÏó¡£
    Each of these data storage locations has a particular cost associated with reading and writing operations involving the data. In most cases, the performance difference between accessing information from a literal value versus a local variable is trivial. Accessing info


Ïà¹ØÎĵµ£º

JavaScript ´´½¨Àà/¶ÔÏóµÄ¼¸ÖÖ·½Ê½

ÔÚJSÖУ¬´´½¨¶ÔÏó£¨Create Object£©²¢²»ÍêÈ«ÊÇÎÒÃÇʱ³£ËµµÄ´´½¨Àà¶ÔÏó£¬JSÖеĶÔÏóÇ¿µ÷µÄÊÇÒ»ÖÖ¸´ºÏÀàÐÍ£¬JSÖд´½¨¶ÔÏó¼°¶Ô¶ÔÏóµÄ·ÃÎÊÊǼ«ÆäÁé»îµÄ¡£
JS¶ÔÏóÊÇÒ»ÖÖ¸´ºÏÀàÐÍ£¬ËüÔÊÐíÄãͨ¹ý±äÁ¿Ãû´æ´¢ºÍ·ÃÎÊ£¬»»Ò»ÖÖ˼·£¬¶ÔÏóÊÇÒ»¸öÎÞÐòµÄÊôÐÔ¼¯ºÏ£¬¼¯ºÏÖеÄÿһÏî¶¼ÓÉÃû³ÆºÍÖµ×é³É£¨ÌýÆðÀ´ÊDz»ÊǺÜÏñÎÒÃdz£Ìý˵µÄHASH±í¡¢× ......

Ò»¼ÒÖ®ÑÔ£ºËµËµ JavaScript µÄÀà³ÉÔ±µÄ·ÃÎÊ¿ØÖÆ

¿´ÊéµÄʱºòÓöµ½ÕâÑùÒ»¸öÎÊÌ⣬³ÌÐò´úÂëÈçÏÂ
var ob = function(){
var obj = this;
function fn1(){
alert( obj === window );//false
alert( this === window );//ture
}
this.fn2 = function() {
fn1();
}

µ±Ê±ºÜ²»Ã÷°×fn1ÀïÃæµÚ¶þ¸öalertµÄ½á¹û£¬Îª ......

javascript calendar

<SCRIPT>
//ÅжÏyÄêµÄÅ©ÀúÖÐÄǸöÔÂÊÇÈòÔÂ,²»ÊÇÈòÔ·µ»Ø0
function leapMonth(y){
return(lunarInfo[y-1900]&0xf);
}
var lunarInfo=new Array(
0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0 ......

javascript Ô­ÐͶÔÏóÓëprototypeµÄ¹ØÏµ

    JavascriptÖеļ̳лúÖÆÊÇËùνµÄÔ­ÐͶÔÏó¼Ì³Ð£¬Í¨¹ýÊôÐÔ·ÃÎÊ»úÖÆµÄÌØÊâÐÔÀ´ÊµÏּ̳еġ£Ö®Ç°ÎÒÒ»Ö±ÒÔΪËùÓжÔÏóµÄÔ­ÐͶÔÏó¾ÍÊÇprototypeËùÖ¸µÄÄǸö¶ÔÏ󡣺óÀ´ÔÚ¿´javascriptÉè¼ÆÄ£Ê½µÄʱºò·¢ÏÖ×÷Õß×¢ÖÐÓÐÒ»¾ä»°ÓëÎÒ֮ǰµÄÀí½â²»Í¬£¬Ëû˵“ÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸öÔ­ÐͶÔÏ󣬵«Õâ²¢²»Òâζ×Åÿ¸ö¶ÔÏó¶¼ÓÐÒ»¸ ......

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

XMLHttpRequest Script Injection  XHR½Å±¾×¢Èë
    Another approach to nonblocking scripts is to retrieve the JavaScript code using an XMLHttpRequest (XHR) object and then inject the script into the page. This technique involves creating an XHR object, downloading the JavaScript f ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ