Type Coercion Playground

Two things on Bayu’s counter and one operator: see every new slip +, -, < or == writes before it acts, including the valueOf and toString calls the engine…

Why it matters

Coercion is a classic source of JavaScript bugs: a form field joined instead of added, an array turned into text, null turned into 0. Know the rules and results that look random become predictable, and it is clear why === and deliberate conversion are safer.

The key idea

+ leans to text, the other operators lean to numbers

Common mistakes

Try it in this playground