0Pricing
JavaScript Academy · Lesson

Implicit Coercion in Operations

Predict how + and comparisons coerce types.

Implicit Coercion

Implicit coercion happens when an operator converts operands to a type that the operation needs. Different operators trigger different conversions.

console.log("5" + 1)
console.log("5" - 1)

Plus With Strings

The plus operator is special: if either operand is a string, it performs string concatenation instead of numeric addition.

console.log("3" + 4)
console.log(3 + "4")
console.log("a" + 1 + 2)

All lessons in this course

  1. Truthy and Falsy Values
  2. Loose vs Strict Equality
  3. Implicit Coercion in Operations
  4. Explicit Conversion Techniques
← Back to JavaScript Academy