Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
How to check if a variable is a boolean type
o = console.log(isNaN(c));
        if(o === false){
            console.log(33);
        }
        if(o === true){
            console.log(39)
        }

Is this the correct way to check if something is of a boolean value|??

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

you can use typeof

 var typeCheck = true
 console.log(typeof typeCheck);
// expected output: "boolean" 

Here is the documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

about 4 years ago · Juan Pablo Isaza Report

0

Just check the type.

If Javascript would not have this feature, you could convert the value to boolean and check with strict comparison.

value === Boolean(value)

function isBoolean(value) {
    return typeof value === 'boolean';
}

console.log(isBoolean(1));
console.log(isBoolean(0));
console.log(isBoolean(true));
console.log(isBoolean(false));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!