== means only compare the value. if you have to used only == equal and they don’t checked the any datatype. if the datatype mismatch then also it will return true.
=== means compare value with the datatype also if both are same then it will return true otherwise it will return false.
Interviews12 answers
What is the difference between == and === in javascript?
12 Answers
both are same functions except === compares the value and datatype so when validate 3==="3" return false because value same but data type string
This is a very standard question for javascript. The answer is as below:
- == will compare the values of the two operands
- === will compare the values and types of the two operands
= is used for assigning values to a variable in JavaScript.
== is used for comparison between two variables irrespective of the datatype of variable.
=== is used for comparision between two variables but this will check strict type, which means it will check datatype and compare two values.
My Article to understand with example.
https://www.c-sharpcorner.com/article/difference-between-and-in-javascript2/
== this will compare value only
and === will compare value as well as type
Follow this video which explain clearly,
This is very common interview question in javascript most of the interviewer asked this kind of question the very basic example is
1 == ‘1’ The result of this answer is true because when we compare two values using double equal then it comapares only value but 1 === ‘1’ this gives us false because this time not only checkes the value but its data type also.
== compares the value
=== compares value and type
- == and === is use for comparaing object
- == is check abstract equality like chanking only values for both side
if(2 == ‘2’) - true. - === is compare data type and value ex.
if(2 === ‘2’) - return false as one variable is int and another is ‘string’








