News for hackers. Stuff that matters.
Re:Google Closure: How not to write JavaScript by _ques on Monday December 13, 2010 @12:45AM (#1999495)
This article is over a year old.
Re:Google Closure: How not to write JavaScript by araneae on Monday December 13, 2010 @01:30AM (#1999594)
True, but as someone who has a java background and is working on js, it's nice to know that switches suck in js :)
Re:Google Closure: How not to write JavaScript by gruseom on Monday December 13, 2010 @01:49AM (#1999636)
I would be very careful (i.e. run my own tests, in multiple browsers) before believing that.
Re:Google Closure: How not to write JavaScript by rbanffy on Monday December 13, 2010 @04:45AM (#1999958)
Or, like my college teachers told me, "measure, don't guess".

I am a bit ashamed to confess I do a lot of guessing in my work...

Re:Google Closure: How not to write JavaScript by wladimir on Monday December 13, 2010 @03:33AM (#1999842)
Reading the article, it seems hard to find anything that does not suck (or at least, is not counter-intuitive) in JS. So many trivialities have to be taken into account.

- You have to store the array length in advance before a loop? wtf?

- "for in" loops are inherently dangerous. wtf?

Every language has pitfalls but javascript seems king above even C++...

Re:Google Closure: How not to write JavaScript by mileszs on Monday December 13, 2010 @08:07AM (#2000321)
> - "for in" loops are inherently dangerous. wtf?

No. "for-in" loops that iterate through the properties of an object, and do something with them, without checking to ensure that the property is specific to that object, as opposed to something another library added to the Object.prototype, are dangerous.

The article did a poor job in that section of pointing out _what_ exactly is dangerous. It's not _every_ for-in loop. It's that one in particular, really.

Re:Google Closure: How not to write JavaScript by brunoc on Monday December 13, 2010 @09:25AM (#2000515)
Most people using for..in in Javascript as beginners really want to use Array.forEach