On 1/14/11, Gary Katsevman <gary.katsev...@gmail.com> wrote:
> The reason why he doesn't like putting the var in the for loops has to
> do with variable hoisting and non-block scope in javascript.
>
> for(var i = 0; i < 5; i++) {
>   print(i);
> }
> i; // undefined in java but 5 in javascript
>

That wouldn't compile in Java.

> He would rather people define the variable outside of the for loop so
> that people realize that the variable is still available after the for
> loop ends.
>
To me that seems more like a style preference than a mistake.
-- 
Garrett

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to