News for hackers. Stuff that matters.
Re:WTF does this code do? by sigvef on Monday March 24, 2014 @01:30PM (#7459666)
This is why you should always use semicolons in JavaScript. Omitting semicolons here turns this:

  var angry = say('Garrrr!')
  
  // what should I say?
  (amIHappy ? happy : angry)()
into this:

  var angry = say('Garrrr!')(amIHappy ? happy : angry)()
Re:WTF does this code do? by zequel on Monday March 24, 2014 @01:48PM (#7459868)
Most web browsers (if you're running this code in a web browser), will do ASI (automatic semicolon insertion).

http://jsfiddle.net/CxUXh/ works fine in Chrome, changing the console.log to an alert.

Not that I'm advocating omitting semicolons!

Re:WTF does this code do? by benvan on Monday March 24, 2014 @02:03PM (#7460007)
Interesting - your jsfiddle exhibits broken behaviour (alerting 'garrr') on my browser - chrome 33.0.1750.152. I believe I'm fairly up to date.
Re:WTF does this code do? by zequel on Monday March 24, 2014 @03:56PM (#7460966)
You're correct, I thought that was expected behavior, my mistake. TBH though, I'm surprised ASI didn't fix the problem, I'll have to look at the rules for insertion again.
Re:WTF does this code do? by dsschnau on Monday March 24, 2014 @04:00PM (#7460998)
Does it return that because `say` isn't defined inside its own function definition, so it evaluates as false?
Re:WTF does this code do? by TophWells on Monday March 24, 2014 @04:42PM (#7461309)
It doesn't seem to do anything.
Re:WTF does this code do? by rainmaking on Monday March 24, 2014 @02:14PM (#7460079)
Hahaha, nice!

I'm getting a linter.

Re:WTF does this code do? by dismal2 on Monday March 24, 2014 @02:32PM (#7460247)
this is idiotic