In various programming languages there is always an operator for comparing 2 expressions, and that is the == operator or "is equal to". This operator compares two expression and returns a boolean.

For example:

1 == 1 - This will return true

1 == 2 - This will return false.

In JavaScript there are 2 types of equality operator, first the double equal signs (==) or the "loose equality", and the triple equal signs (===) or the "strict equality".

So what's the difference between the two?

TL;DR - the other one is much stricter than its counterpart. LOL.

Loose Equality

Loose equality is the equality operator that checks if the expressions are equal in value, but in doesn't check if they have equal data types. This can be useful if you are comparing 2 expressions that you are sure has the same data type, e.g. they are both number.

For example:

1 == 1 // true
1 == '1' // true - notice that the other expression is a string
1 == 2 // false

'one' == 'one' // true
'one' == 'two' // false

However, this can be confusing if the 2 expressions have the same value but different data type.

For example, 1 == '1' will return true. It doesn't make sense right? That's why it's safer to use strict equality operator.

Strict Equality

Strict equality on the other hand has much stricter checking. It doesn't just compare the value, but the data type as well. That's why this is always preferred by most javascript developers. This will lessen the chance of having a bug especially if you're program is handling numbers.

For example:

1 === 1 // true
1 === '1' // false - there you go

1 === 'one' // false - of course!

In conclusion, always use the strict equality, it's recommended by most linters out there anyways, so the chance of you stumbling upon companies or teams who still uses loose equality operator much lesser than those who don't.