Hello Friends 👋,
Welcome To Infinitbility! ❤️
Today, we will know easiest way to convert number to boolean in typescript.
TypeScript have !! double exclamation
which help you to convert number to boolean like when we add double exclamation with 1
it will return true
, with 0
it will return false
.
Take an example
1let statusZero: number = 0;2let statusOne: number = 1;34console.log(!!statusZero) // false5console.log(!!statusOne) // true
Output

The
!! double exclamation
return false for0
only else it returntrue
for any number.
Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.