[·Òë]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
Ïà¹ØÎĵµ£º
±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔÀ´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷ÔÒò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......
ÔÚJSÖУ¬´´½¨¶ÔÏó£¨Create Object£©²¢²»ÍêÈ«ÊÇÎÒÃÇʱ³£ËµµÄ´´½¨Àà¶ÔÏó£¬JSÖеĶÔÏóÇ¿µ÷µÄÊÇÒ»ÖÖ¸´ºÏÀàÐÍ£¬JSÖд´½¨¶ÔÏó¼°¶Ô¶ÔÏóµÄ·ÃÎÊÊǼ«ÆäÁé»îµÄ¡£
JS¶ÔÏóÊÇÒ»ÖÖ¸´ºÏÀàÐÍ£¬ËüÔÊÐíÄãͨ¹ý±äÁ¿Ãû´æ´¢ºÍ·ÃÎÊ£¬»»Ò»ÖÖ˼·£¬¶ÔÏóÊÇÒ»¸öÎÞÐòµÄÊôÐÔ¼¯ºÏ£¬¼¯ºÏÖеÄÿһÏÓÉÃû³ÆºÍÖµ×é³É£¨ÌýÆðÀ´ÊDz»ÊǺÜÏñÎÒÃdz£Ìý˵µÄHASH±í¡¢× ......
C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
ÎÊ£º
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
3.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptµÄÒÑÓбäÁ¿?
4.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptº¯Êý?
ÎÊÌâ1´ð°¸ÈçÏ£º
javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ ......
<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 ......
<html>
<body>
<script type="text/javascript">
//·½·¨Ò»
var num_arr= [];
for (var i = 0 ; i < 10 ; i ++)
{
num_arr[i] = i;
}
document.write(num_arr+'</br>');
//·½·¨¶þ
var obj_arr=new Array();
obj_arr[6]='ss';
document.write(obj_arr.len ......