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
let statusZero: number = 0;
let statusOne: number = 1;
console.log(!!statusZero) // false
console.log(!!statusOne) // true
Output
The
!! double exclamationreturn false for0only else it returntruefor any number.
Thanks for reading…