mika-el
5/23/2019 - 10:13 AM

!! Bang Bang Operator

/*
  Okay, technically its not a separate JavaScript operator. It’s just the JavaScript negation operator used twice.
  But Bang Bang sounds so cool! Bang Bang or Double Bang is a neat trick to convert any expression to a Boolean value.
  If the expression is a truthy value, it return true; otherwise it returns false.
*/

!!null      // returns false
!!undefined // returns false
!!false     // returns false
!!true      // returns true
!!""        // returns false
!!string    // returns true
!!0         // returns false
!!1         // returns true
!!{}        // returns true
!![]        // returns true