1. == (Double equals) is for loose equality. Returns true for somewhat logically equal operands. This is because their types are converted to same type before comparing.
  2. === (Triple equals) is for strict equality. Returns true if both operands are same type and value.
  3. != is for loose inequality. Performs type coercion like ==
  4. !== is for strict inequality. Both type and value are involved.

Predictable Behavior

Recommended to use === in most cases

Further comparison

OperatorDescriptionExampleResult
==Converts operands to the same type before comparing.1 == '1'true
==Converts true to 1 and false to 0 before comparing.true == 1true
==Converts operands to numbers if one is a number.0 == falsetrue
===Strict Equality: No type conversion, compares both value and type.1 === '1'false
===Both operands must be of the same type and value.1 === 1true
===No type conversion; different types mean false.true === 1false

Confusing comparison

Scenario== (Double Equals)=== (Triple Equals)
1 with "1"truefalse
0 with ""truefalse
null with undefinedtruefalse
[1] with [1]falsefalse
({}) with ({})falsefalse