0

What is a double !! operator means in JavaScript? I tried to look into JS docs operator and I can't find out what is !! means for.

!!item.length && (!!item.sum || !!item.indicator)
  • 1
    it's literally two ! operators, firstly it negates the value, and then negates it again, giving you a boolean representation of the value, people just tend to prefer writing `!!val` over `Boolean(val)`. It saves characters making it easier for browsers to download script files, for instance google compilers even turn `false` into `!1` to save characters so there are reasons behind writing it this way – Krzysztof Krzeszewski Oct 28 '20 at 08:51
  • https://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript#:~:text=55,10%20false%20%3D%3D%3D%20!!0 – Nooruddin Lakhani Oct 28 '20 at 08:52
  • it basically converts variables into boolean – Simon Oct 28 '20 at 09:05
  • Ohh okay thank you guys, much appreciate! – stormbreaker Oct 29 '20 at 01:47

0 Answers0