Type Coercion in JavaScript — a practical guide to JavaScript type coercion with clear examples you can reuse in real projects.
JavaScript Tutorial Series (15/101). Prefer one article? Read the complete JavaScript tutorial.
Short description
Use === and !== to avoid surprising coercion.
Coercion pitfalls
1 + '2'; // '12'
1 == '1'; // true
1 === '1'; // false
[] == false; // true (weird)