✅ Boolean,null,undefined Data Type
Last Updated: 8th Oct 2025
Booleans Data Type
- A Boolean data type represents only two values →
trueorfalse. - It is often used in conditions, comparisons, or logical decisions in a program.
- Think of it as an ON/OFF switch — either something is or is not.
Hinglish Tip 🗣: Boolean matlab sirf do hi jawab — “Haan (true)” ya “Nahi (false)”. JavaScript me ye decision lene ke kaam aata hai jaise condition check karna.
let isOnline = true;
let isLightOn = false;
console.log(isOnline); // true
console.log(isLightOn); // false
console.log(typeof isOnline); // "boolean"
Null Data Type
- A null value represents the absence of any object value.
- It is often used to represent a missing or unknown value in a program.
- Think of it as a placeholder for a missing value.
let user = null;
console.log(user); // null
console.log(typeof user); // "object"
Undefined Data Type
- An undefined value represents the absence of a value.
- It is often used to represent a variable that has not been assigned a value yet.
- Think of it as a variable that has not been initialized yet.
let age;
console.log(age); // undefined
console.log(typeof age); // "undefined"
🧠 Truthy and Falsy Values
In JavaScript, some values automatically act as true or false in conditions — even if they are not explicitly true or false.
Falsy Values (act as false):
false0""(empty string)nullundefinedNaN(Not a Number)
Truthy Values (act as true):
true- Any number (except
0) - Any string (except the empty string)
- Any object
- Any array (except the empty array)
Hinglish Tip 🗣: JavaScript me sab kuch clearly true/false nahi hota — kuch values “truthy” aur kuch “falsy” behave karti hain. Ye condition me automatic conversion hota hai.