Topic awaiting preservation: Which method is optimal |
|
---|---|
Author | Thread |
Bipolar (III) Inmate From: |
posted 07-24-2003 04:12
I was just reading that JScript processes variable declarations before executing any code. So which construct is optimal? |
Maniac (V) Inmate From: Cell 666 |
posted 07-24-2003 04:40
It only seems logical that declaring variables at the head of the script would be better. |
Paranoid (IV) Inmate From: NZ |
posted 07-24-2003 04:51
I agree, mate. |
Maniac (V) Inmate From: Brisbane, Australia |
posted 07-24-2003 04:59
I agree, variable declarations should be done prior to anything else, unless the logic of your code requires otherwise. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 07-24-2003 05:11
There's probably no difference at all in speed between the two constructs. Of course, it might depend on the individual browser. But even if there is a difference, you'll never notice it. |
Bipolar (III) Inmate From: |
posted 07-25-2003 03:10
Thanks fellas. I moved all my var declarations to the beginning of the script I'm working on and what I didn't move I converted to local vars by creating a few new functions. I did note a slight speed boost but it is a rather large script with a lot of vars. On a normal sized script I probably couldn't tell any difference. |