Difference between == and === with Example-JavaScript

Difference between == and === with Example-JavaScript

Hey Readers,

This is one of the most frequently asked question in interview when one tries to judge your jQuery or JavaScript concepts.

JavaScript provides different types of operators. Here, we will be talking about strict equality and Type converting equality.

Difference between == and === with Example-JavaScript #difference #javascript Click To Tweet

Type converting equality (==) means automatically it will convert variable to value irrespective of data type, either it is string or number. This means “2” will be equal to 2 (“2″== 2 it will return true). So the double equal (==) is an auto type converting equality and three equal (===) is strict equality operator i.e it will not convert values automatically.

Difference between == and === with Example-JavaScript

Difference between == and === with Example – JavaScript

Below is the demonstration with simple examples:

Demo 1

1==”1″ // it will return true because here string will converted as number
1 === “1” // it will return false because here 1 is number and “1” is string

Demo 2

0 == false // it will return true because here false is equivalent of 0
0 === false // it will return false because both are different operands

I have included the complete example for you to check the result yourself as shown below:

Run the below examples to see live results

Hope you enjoyed this post and gained knowledge about the difference between double and triple equals sign in JavaScript or jQuery.

What do you think?

Dear Reader,
If you have any questions or suggestions please feel free to email us or put your thoughts as comments below. We would love to hear from you. If you found this post or article useful then please share along with your friends and help them to learn.

Happy Learning!