DEV Community

Raghav Rathi
Raghav Rathi

Posted on

2

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)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay