Type Coercion
Type coercion is the automatic or implicit conversion of values from one data type to another.
Key concepts
Type Coercion
The automatic or implicit conversion of values from one data type to another.
Implicit Coercion
Automatic conversion performed by JavaScript.
Explicit Coercion
Manual conversion using functions like Number(), String(), Boolean().
Examples
Implicit Coercion:
console.log('5' + 5); // "55" (string concatenation)
console.log('5' - 2); // 3 (string converted to number)Explicit Coercion:
const str = '123';
const num = Number(str);
console.log(num); // 123Stuck on this one? Talk to Sumit.
Keys: F focus mode · ← → previous / next topic · Esc leave focus