Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Boolean in Javascript
interview

Q1. What is Boolean in JavaScript?
Boolean is a data type that represents logical values. It can have only two possible values:
  • true
  • false
Booleans are mainly used in conditions, comparisons, and decision-making.

Example
let isLoggedIn = true;
let isAdmin = false;


Q2. Where Are Boolean Values Commonly Used?
Boolean values are commonly used in:
  • Conditional statements
  • Comparison operations
  • Loops
  • Logical operations
  • Form validations
Example
let age = 18;

if(age >= 18) {
    console.log(true);
}


Q3. How Are Boolean Values Created in JavaScript?
Boolean values can be created in two ways:

1. Direct Assignment
let status = true;

2. Using Comparison
let result = 10 > 5;
console.log(result);

Output
true


Q4. What is Boolean Conversion in JavaScript?
JavaScript automatically converts values into Boolean when used in conditions. This process is called Boolean conversion.

Example
Boolean(1);      // true
Boolean(0);      // false
Boolean("");     // false
Boolean("Hello"); // true