Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......

ʹÓÃJavaScriptÁ¬½ÓSqlServerÊý¾Ý¿â¡£Ö´ÐÐCRUD²Ù×÷¡£

function db()
{
//»î¶¯±àºÅ
var activeid = Request.Form("activeid");
//Óû§Ãû
var username = Request.Form("username");
//ÊÖ»úºÅÂë
var mobile = Request.Form("mobile");
var conn= Server.CreateObject("ADODB.connection");
var rs= Serve ......

javascript cookies ´æ¡¢È¡¡¢É¾³ýʵÀý

<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿­
function
SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
    var Days = 30;
//´Ë cookie ½«±»±£´æ 30 Ìì
    var exp  = new Date();    //new
Date("December 31, 9998");
    ......

Javascript±Õ°ü(Closure)

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

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

Repaints and Reflows  ÖØ»æºÍÖØÅŰæ
    Once the browser has downloaded all the components of a page—HTML markup, JavaScript, CSS, images—it parses through the files and creates two internal data structures:
    µ±ä¯ÀÀÆ÷ÏÂÔØÍêËùÓÐÒ³ÃæHTML±ê¼Ç£¬JavaScri ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ