2 August 2011

Good to know: About declaring var

"It’s a good practice to also initialize the variable with an initial value at the time you declareit. This can prevent logical errors (all uninitialized and declared variables are initialized.When you look at the
code later, you can get an idea about the intended use of a variable based on its initial
value—for example, was it supposed to be an object or an integer?

"

Source: Stoyan Stefanov - JavaScript Patterns  - O'Reilly(2010)

No comments:

Post a Comment