Can an int be converted into a boolean?

 

To convert an integer to a boolean us Boolean() method 

The boolean method  converts integers with a value of zero to false and all other integers to true and returns the result.

 

console.log(Boolean(1));
// true

console.log(Boolean(0));
// false

console.log(Boolean(-0)); 
// true

console.log(Boolean(-1));
// false

Tags:

Share:

Related posts