Type Coercion
Definition
JavaScript's automatic conversion of values from one type to another during operations. Implicit coercion happens with operators like `==`, `+`, and in boolean contexts. Explicit coercion uses functions like `Number()`, `String()`, `Boolean()`.
Code Example
Javascript
Tip: Modify the code above and click “Run” to see the results
Learn More
Related Terms
Truthy and Falsy
In JavaScript, every value is either truthy or falsy when evaluated in a boolean context. Falsy values are: false, 0, '', null, undefined, NaN, and 0n. Everything else is truthy, including empty arrays and objects.
Strict EqualityThe === operator that checks both value and type without type coercion. Unlike == (loose equality), strict equality does not convert operands before comparing. Always prefer === over ==.