t_ravichandu
09-22-2005, 07:46 AM
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.
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
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
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.
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
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