DEV Community

Felix Twoli
Felix Twoli

Posted on

Difference between =, == and === operators

The =, ==, and === operators are all used for comparison in programming.

= operator

The = operator is used to assign a value to a variable.

Depending on the value of the operand that is available on the right side, the = JavaScript operator assigns a value to the left operand. A variable should be the first operand.

let x = 10
= has been used to assigned value of 10 to x

== operator

The == operator is used to check if two values are equal.

x == y

=== operator

The === is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar type.
The === operator is used to check if two values are equal and of the same type.
When two variables have numerical values, they are regarded as equal if they both have the same value and neither is NaN (Not a Number).
x ==== y Returns true if the operands are equal and of the same type.

Top comments (0)