Type Coercion
noun
say it: “TYPE koh-ER-zhun” /taɪp koʊˈɜːrʒən/ or “TYPE koh-UR-shun” /taɪp koʊˈɜːrʃən/
JavaScript changing a value from one type to another, such as text to a number, either because you asked it to or on its own when two types meet.
What is Type Coercion in JavaScript?
Type Coercion — JavaScript's conversion of a value from one type to another, either automatically or explicitly.
const quantityText = "3";
const quantity = Number(quantityText);
In a sentence
- “Because of type coercion, "3" * 2 came out as the number 6.”
- “Type coercion is why '5' + 1 gave me '51' instead of 6.”
Level: Novice · More JavaScript terms at this level
Updated