-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Rohit_BD
Message 25 in Discussion




  
    
    New Message on MumbaiUserGroup
  
  





      JavaScript help

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 15 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Rohit_BD
            
            
              

              


  
    
    New Message on MumbaiUserGroup
  
  





      JavaScript help

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 10 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Rohit_BD
            
            
              

              A circular reference will cause a program written in any language 
to crash, given the right (or wrong) logical structure of the code - just that 
the runtime specific to the language handles it in it's own way. For example, 
the IE browser will stop a script if it runs for more than 10 seconds or so - 
even though it may just be due to a loop that's got many iterations. Recursive 
functions tend to cause JavaScript code to fail - the remedy is as follows:
/* This version may fail in the browser */
var i = 0;

function MyFunc()
{
/**/ if(i > 10000) return;
/**/ i++;
/**/ MyFunc(); /* Call MyFunc() recursively */
}

/* This version works in the browser */
var i = 0;

function MyFunc()
{
/**/ if(i > 10000) return;
/**/ i++;
/**/ setTimeout("MyFunc();", 100); /* Just added a 100mS delay before 
recursively calling MyFunc(). */
}

If you notice, both versions are recursive and convergent (i.e., they converge 
towards an end), but the 1st version fails - a problem similar to circular 
reference. The 2nd version works - but again this depends on the browser's 
script time-out limit.
          
        
      
          
  

    View other groups in this category.
  

  

      



          
        
      
          
  

    View other groups in this category.
  

  

      




-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to