## DEV Community

Etulan

Posted on • Updated on

# Difference between =, ==, and === in JavaScript

First, What is an operator?

JavaScript operators are used to assign values, compare values, perform arithmetic operations e.t.c.

# Classes of Operators

*Assignment Operators
*Arithmetic Operators
*Comparison Operators
*String Operators
*Conditional Operators
*Logical Operators
*Bitwise Operators
*Relational Operators
*Unary Operators and more...

For this article, I will only focus on those operators that include =, ==, ===.

# Assignment Operators

Assignment operators assign values to variables in JavaScript. It assigns values to its left operand based on the value of its right operand.

# Arithmetic Operators

They perform an arithmetic operation between numerical variables and/or values. They include +, -, (*), (/), %, ++, --.

# Comparison Operators

Comparison operators are used in determining the equality or difference between variables or values. Comparison operators are further divided into two, the equality operators and relational operators.

## Equality Operators

1. Equality Operator (==) equal to
2. Inequality operator (!=) not equal
3. Identity operators (===) equal value and equal type
4. NonIdentity operators (!==) not equal value and not equal type

### Equality Operator (==)

This checks whether its two operands are equal and returns a boolean result.

### Identity Operator ===

The strict equality operator (===) checks whether its two operands are equal and of the same type, returning a Boolean result.

# Differences between =, ==, ===;

1. Firstly, = is an assignment operator whereas the other two are equality (comparison) operators.
2. = assigns a value to a variable. == compares two variables while ignoring the data type of each variable. === compares two variables in terms of its values and data types (string, number).
3. = returns a string or number == returns a boolean expression, true if the values are equal and false if they are not. === also returns a boolean expression, true if both the values and data types are equal and false if either value/datatype is not equal.