4 ms·
Also, "scope" means inside a function, and not inside a control block (e.g. for loops). I would estimate global variables will cause at least 50% of the headac
by tyrmored 17y ago
Also, "scope" means inside a function, and not inside a control block (e.g. for loops).
I would estimate global variables will cause at least 50% of the headaches an intermediate JavaScript developer experiences. It's particularly bad when you're dealing with rows of data, for example.
Get in the habit of declaring every variable in the top line of the function concerned before you use it. If you haven't already mastered closures, this will make things a lot easier for you.