DEV Community

Raghav Rathi
Raghav Rathi

Posted on

Using `!!` to Convert to Boolean

Quickly convert any value to a boolean by using double negation.

let truthyValue = !!1; // true
let falsyValue = !!0; // false
Enter fullscreen mode Exit fullscreen mode

NOTE

  • 1 can be any true value
  • 0 can be any false value

For more refer


Learn from: https://dev.to/mmainulhasan/30-javascript-tricky-hacks-gfc

Top comments (0)