Type Coercion & Truthy/Falsy in JavaScript

🟢 Beginner Level | JavaScript Core Syntax

📖 Definition

Type Coercion is the automatic/implicit conversion of values from one data type to another during operations. Type Conversion is explicit casting using functions like Number(), String(), and Boolean().

🌐 Multilingual Summary

English

Use === to avoid implicit coercion bugs. Falsy values: false, 0, -0, 0n, "", null, undefined, NaN.

Hindi

Implicit conversion se bachne ke liye hamesha strict equality === use karein.

⚡ Code Example

console.log("5" + 2);  // "52" (String concatenation)
console.log("5" - 2);  // 3 (Implicit numeric conversion)
console.log(Boolean("")); // false (Empty string is falsy)

🧭 Navigation

← 02. Reference Data Types & Heap Memory | Module Hub | Module Hub →