Type Coercion

A language that converting the value of certain type to another type. All languages do this type conversion

When the operands at the left and right of the operator is of different type, one of the value is converted to equivalent value by JavaScript engine.

1 == '1'; // true
1 != '1'; // false

In JavaScript this happens only if we use == operator.

1 === '1'; // false
1 !== '1'; // true

If we use ===, that means compare two values but don't coercive the values.

Last updated