0

a ternary operator is something like isHot ? 'I am sweating': ''

but there is something shorter like isHot && 'I am sweating'

what is it called?

nxmohamad
  • 1,731
  • 2
  • 19
  • 31
  • what should happen with the result? what is the content of `isHot`? – Nina Scholz Nov 20 '17 at 08:42
  • 3
    that's just [the Logical && (AND) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators). Aplying it like that is called short-circuit evaluation. – Cristian Lupascu Nov 20 '17 at 08:43
  • These are not the same, the corresponding ternary of `isHot && 'I am sweating'` would be `isHot ? 'I am sweating' : isHot` and the corresponding AND version of `isHot ? 'I am sweating': ''` would be `isHot && 'I am sweating' || ''` – Kaiido Nov 20 '17 at 08:45
  • @GolfWolf do post your comment as answer :) – nxmohamad Nov 20 '17 at 16:47

0 Answers0