Skip to content

Comment on WTF does this code do?

Comments

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)()
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.