Navigate back to the homepage

How to convert number to boolean in typescript?

Infinitbility
TypeScript
January 31st, 2022 · 1 min read
keep affilitate

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;
3
4console.log(!!statusZero) // false
5console.log(!!statusOne) // true

Output

TypeScript, number, to, boolean, example
TypeScript, convert number to boolean example

The !! double exclamation return false for 0 only else it return true 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.

melio affilitate

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How to remove keys with null values in javascript?

Javascript, remove keys with null values example.

January 30th, 2022 · 1 min read

How to convert number to decimal in typescript?

TypeScript, convert number to decimal example.

January 29th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]