How to check if type is boolean in Node.js

2 Answers

0 votes
const bool = true;

if (typeof bool === 'boolean') {
  	console.log('boolean');
} else {
  	console.log('not boolean');
}


  
  
  
/*
run:
  
boolean
  
*/

 



answered May 26, 2022 by avibootz
0 votes
console.log(typeof true);
console.log(typeof false); 


  
  
  
/*
run:
  
boolean
boolean
  
*/

 



answered May 26, 2022 by avibootz

Related questions

1 answer 132 views
1 answer 107 views
1 answer 109 views
2 answers 179 views
1 answer 153 views
2 answers 165 views
...