+ 12

What is the difference between == and === operators in JavaScript?

23rd Jul 2018, 2:30 AM
Nandhini Murugesan
Nandhini Murugesan - avatar
8 odpowiedzi
+ 20
== checks both values are equal or not. and === checks both are equal or not and also types are equal or not example var x=5; x =='5'; it will return true . because Values are matched var x=5; x ==='5'; it will return false. because values are matched but data type is different. Variable x having integer value which is compared with string value(written in ' ' )
23rd Jul 2018, 3:24 AM
Sunny
Sunny - avatar
+ 5
== checks only values, === checks both values and types
24th Jul 2018, 12:36 PM
KarSah
KarSah - avatar
+ 4
=== in JavaScript is called as strict equal operator and == operator is known as equality operator. the output given by === is more precise than the == in JavaScript
24th Jul 2018, 3:56 PM
yuvan bajjurla
yuvan bajjurla - avatar
+ 2
== checks both values are equal or not. and === checks both are equal or not and also types are equal or not example var x=5; x =='5'; it will return true . because Values are matched var x=5; x ==='5'; it will return false. because values are matched but data type is different. Variable x having integer value which is compared with string value(written in ' ' )
25th Jul 2018, 2:11 PM
Md dilshad alam
Md dilshad alam - avatar
+ 2
== means both values have content comparison === means it will check both values of their datatypes
25th Jul 2018, 4:22 PM
Vasavi
+ 2
== will at first converts them into same type(usually number) and then compares them, the === operator only compares. You can find more information about the algorithm of the == operator here in the section 11.9.3 https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
25th Jul 2018, 7:44 PM
Geek Girl
Geek Girl - avatar
+ 2
== just to check the equality === is to check the identity. when using ===, the both value and the type must be same. when i say the type, i mean object, string, etc. if u compare an object and a string having same value and using === to compare them. you will get false result.
28th Jul 2018, 6:21 PM
Arun C
Arun C - avatar