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

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

Recursion Patterns  µÝ¹éģʽ
    When you run into a call stack size limit, your first step should be to identify any instances of recursion in the code. To that end, there are two recursive patterns to be aware of. The first is the straightforward recursive pattern represented in the factorial() function shown earlier, when a function calls itself. The general pattern is as follows:
    µ±ÄãÏÝÈëµ÷ÓÃÕ»³ß´çÏÞÖÆÊ±£¬µÚÒ»²½Ó¦¸Ã¶¨Î»ÔÚ´úÂëÖеĵݹéʵÀýÉÏ¡£Îª´Ë£¬ÓÐÁ½¸öµÝ¹éģʽֵµÃ×¢Òâ¡£Ê×ÏÈÊÇÖ±½ÓµÝ¹éģʽΪ´ú±íµÄÇ°ÃæÌáµ½µÄfactorial()º¯Êý£¬¼´Ò»¸öº¯Êýµ÷ÓÃ×ÔÉí¡£ÆäÒ»°ãģʽÈçÏ£º
function recurse(){
  recurse();
}
recurse();
    This pattern is typically easy to identify when errors occur. A second, subtler pattern involves two functions:
    µ±·¢Éú´íÎóʱ£¬ÕâÖÖģʽ±È½ÏÈÝÒ×¶¨Î»¡£ÁíÍâÒ»ÖÖģʽ³ÆÎª¾«ÇÉģʽ£¬Ëü°üº¬Á½¸öº¯Êý£º
function first(){
  second();
}
function second(){
  first();
}
first();
    In this recursion pattern, two functions each call the other, such that an infinite loop is formed. This is the more troubling pattern and a far more difficult one to identify in large code bases.
    ÔÚÕâÖֵݹéģʽÖУ¬Á½¸öº¯Êý»¥Ïàµ÷ÓöԷ½£¬ÐγÉÒ»¸öÎÞÏÞÑ­»·¡£ÕâÊÇÒ»¸öÁîÈ˲»°²µÄģʽ£¬ÔÚ´óÐÍ´úÂë¿âÖж¨Î»´íÎóºÜÀ§ÄÑ¡£
    Most call stack errors are related to one of these two recursion patterns. A frequent cause of stack overflow is an incorrect terminal condition, so the first step after identifying the pattern is to validate the terminal condition. If the terminal condition is correct, then the algorithm contains too much recursion to safely be run in the browser and should be changed to use iteration, memoization, or both.
    ´ó¶àÊýµ÷ÓÃÕ»´íÎóÓëÕâÁ½ÖÖģʽ֮һÓйء£³£¼ûµÄÕ»Òç³öÔ­ÒòÊÇÒ»¸ö²»ÕýÈ·µÄÖÕÖ¹Ìõ¼þ£¬ËùÒÔ¶¨Î»Ä£Ê½´íÎóµÄµÚÒ»²½ÊÇÑéÖ¤ÖÕÖ¹Ìõ¼þ¡£Èç¹ûÖÕÖ¹Ìõ¼þÊÇÕýÈ·µÄ£¬ÄÇôËã·¨°üº¬ÁËÌ«¶à²ãµÝ¹é£¬ÎªÁËÄܹ»°²È«µØÔÚä¯ÀÀÆ÷ÖÐÔËÐУ¬Ó¦µ±¸ÄÓõü´ú£¬ÖÆ


Ïà¹ØÎĵµ£º

ͨ¹ýjavascript»ñµÃurl²ÎÊý

Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£ 
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......

javascript¼Ì³Ð·½Ê½Ö®Ò»

ÃæÏò¶ÔÏóµÄÓïÑÔ¶àÊý¶¼Ö§³Ö¼Ì³Ð£¬¼Ì³Ð×îÖØÒªµÄÓŵã¾ÍÊÇ´úÂ븴Ó㬴Ӷø¹¹½¨´óÐÍÈí¼þϵͳ¡£Èç¹ûÒ»¸öÀàÄܹ»ÖØÓÃÁíÒ»¸öÀàµÄÊôÐԺͻò·½·¨£¬¾Í³ÆÖ®Îª¼Ì³Ð¡£
´ÓÕâ¸ö½Ç¶ÈÀ´¿´¿´jsµÄ¼Ì³Ð·½Ê½¡£jsÖм̳з½Ê½ÓëдÀ෽ʽϢϢÏà¹Ø¡£²»Í¬µÄдÀ෽ʽÔì³É²»Í¬µÄ¼Ì³Ð·½Ê½¡£¸÷ÖÖÁ÷ÐÐjs¿â¼Ì³Ð·½Ê½Ò²¸÷²»Ïàͬ¡£´Ó×î¼òµ¥µÄ
¸´ÓÿªÊ¼¡£
1¡¢¹¹Ôìº ......

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


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

javascript¶¯Ì¬×°ÈëXMLÊý¾Ý


ʹÓÃjavascript´´½¨Microsoft XML DOM,¾Í¿ÉÒÔÍê³ÉÕâÒ»¹¤×÷.
// ×°ÈëÊý¾Ý.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// ×°ÈëÑùʽ±í.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......

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

Conditionals  Ìõ¼þ±í´ïʽ
    Similar in nature to loops, conditionals determine how execution flows through JavaScript. The traditional argument of whether to use if-else statements or a switch statement applies to JavaScript just as it does to other languages. Since different b ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ