What is the difference between (==) and (===)?

What is the difference between (==) and (===)?

·

1 min read

Hello everyone! today we are going to talk about the difference between double(==) and triple(===).

so, the double (==) and triple(===) a both are used for comparison, but they behave very differently.

Let's see what double(==) offers!

const a = 5;
const b = "5";

a == b; // returns true

so, it shouldn't return true because a is a number type and b is a string type!

Let's see what triple(===) offers!

const a = 5;
const b = "5";

a===b; //returns false

so, tripel(===) compares both values and checks data types as well.

In conclusion, you should use === operator, which checks for both value and data type equality without any type of coercion. By using ===, you can write more reliable and bug-resistant code.

Thanks, everyone hanging in there till the last ❤️!!

Find me on Twitter and LinkedIn.