Re:Writing Eloquent JavaScript Without CoffeeScript
by mquander on Friday December 09, 2011 @11:31AM
(#3334309)
Oscar, when your code itself is making little frowny faces at you after you write it, something has gone wrong.
[ Parent
| on HN ]
Re:Writing Eloquent JavaScript Without CoffeeScript
by scarmig on Friday December 09, 2011 @12:35PM
(#3334604)
Does javascript guarantee a particular order of expression evaluation when there aren't any sequence points?
Alerting 'All Fixed' and afterwards 'Error' seems like it'd be just as valid an interpretation of the code.
Edited to add: Actually, I think the comma operator does do that, so no bad. Though the code is still unsightly...
Re:Writing Eloquent JavaScript Without CoffeeScript
by ryankshaw on Friday December 09, 2011 @01:41PM
(#3334926)
lol, after reading the article I came back in here to call out that exact same chunk of code and the exact same sad face. I will agree, however for small things the ternary operator is prettier than the if...then...else... syntax
thing[conditional ? 'show' : 'hide']();
instead of:
thing[if conditional then 'show' else 'hide']()