Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-22-2005, 07:46 AM
  #1
t_ravichandu
Myrmidon (Level 12)
 
t_ravichandu's Avatar
 
Join Date: Apr 2004
Posts: 171
iTrader: (0)
t_ravichandu is on a distinguished road
optimized script execution time

Hi,
I have a snippet of javascript in a for loop where I need to assign the value of a variable to another 2 variables. Some thing like this.
Code:
cnt = arrayTemp.length;
for(i = 0; i < cnt; i++) {
    m = k;
    n  = k;
}
It is apparent that the two statements in the for loop can be written in a single statement. like
Code:
cnt = arrayTemp.length;
for(i = 0; i < cnt; i++) {
    m = n = k;
}
Since the for loop's iterations may go to several thousands at time, I would like to know which code is the optimum one and please tell me why!
Thanx in advace
t_ravichandu is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-22-2005, 10:05 AM
  #2
smartweb
Chevalier (Level 6)
 
Join Date: Sep 2005
Posts: 52
iTrader: (0)
smartweb is an unknown quantity at this point
I don't think there will be a difference speed wise, but you can always run a test to compare both.
smartweb is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 11:56 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.