inefficient to check value of a checkbox?

K

Kourosh

I have a big loop that checks the value of a checkbox several times
(1000+ times)
I'm just wondering, would it be any more efficient to save the value of
the checkbox outside the loop and the read that variable inside the
loop instead?

ie, I have this
for (var i=0;...)
doStuff (form1.checkbox1.checked);


versus
var chk = form1.checkbox1.checked;
for (var i=0;...)
doStuff (chk);
 
R

Randy Webb

Kourosh said the following on 5/26/2006 2:54 PM:
I have a big loop that checks the value of a checkbox several times
(1000+ times)
I'm just wondering, would it be any more efficient to save the value of
the checkbox outside the loop and the read that variable inside the
loop instead?

ie, I have this
for (var i=0;...)
doStuff (form1.checkbox1.checked);


versus
var chk = form1.checkbox1.checked;
for (var i=0;...)
doStuff (chk);

Do the second. It keeps from having to look up that property 1000 or so
times and as such will *always* be faster.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top