+ 24
What is the difference between '==' & '===' operators?
28 Réponses
+ 10
== equal to comparison
=== Identical(equal and of the same type)
+ 7
== this check only value but === this check value and data type. Ex 2===2 same value and same data type but 2=="2" same value but not same data type.
+ 6
Please use search bar before, to avoid dublicates... Hope these helps you.. Thank you..
https://www.sololearn.com/discuss/1922428/?ref=app
https://www.sololearn.com/discuss/364595/?ref=app
https://www.sololearn.com/discuss/1213035/?ref=app
https://www.sololearn.com/discuss/542577/?ref=app
https://www.sololearn.com/discuss/468107/?ref=app
https://www.sololearn.com/discuss/602535/?ref=app
https://www.sololearn.com/discuss/1419547/?ref=app
+ 6
"1" == 1 is true. But
"1" === 1 is false.
+ 3
== 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.
+ 3
== is used to conpare two values
=== is used to compare two values and their type
+ 2
== only compares the values but === compares values and types
For example:
$a = 1;
$b = "1";
$a == $b ; returns TRUE because the both have the same value that is 1
$a === $b; returns FALSE because the value of $b wrote in double quotation " " and it's defined as string type while the $a value has not quotation and defined as integer
So and integer is not same as string type and it returns false
+ 2
If the comparison is between the same value type both == and === do exactly the same thing. If the value types being compared are different the == differs from === in that it allows type conversion before the comparison.By default the non-number values ("5",true,false) to be converted to numbers (5,1,0) before the comparisons are made. For more details see https://github.com/Li-YangZhong/You-Dont-Know-JS/blob/2nd-ed/get-started/ch2.md here
+ 2
== compares only the value.
=== compares value and type.
e.g. 5 == "5" is true.
5 === "5" is not true.
+ 2
== checks two variables same or not, it doesn't check the data type.
=== checks two variables same or not and the data type must have to be same.
"1" == 1 it will return true. Here the 1st 1 is string and the 2nd 1 is integer. It is true because the values are same.
"1" === 1 it will return false. Though the values are same but the data types doesn't match.
+ 2
'==' denote equal to
For example :
10==10; its true
And
'===' its identically equal to and same
For example
10===10
+ 1
Thanks
+ 1
Sorry
+ 1
Jitendra Kumar
No need to be sorry. Don't say that.. Its just information and a request giving to you.. Because dublicates may gets deleted by mods to keep search bar, & SL clean..
So information only..
+ 1
== only checks the content if they match. Like string "1" & integer 1. It will return true because content is same though data types are not same.
But === also checks if they are of same data type,which in above case is not true, as "1" is string & 1 is number. So that will return false now.
+ 1
JavaScript has an incredibly weird typesystem. To fix this, == will check if they are the same regardless of type whilst === will check the type. Examples:
‘0’ == 0 // True
‘0’ === 0 // False
0 == 0 // True
0 === 0 //True.
I do not know much about JS other than the bare basics, but I’d imagine that you should use === instead of == most of the time.
+ 1
double equal is for compare
'5' == 5 --> true
three equal is identical
'5' === 5 --> false
Show '5' is a string, but 5 is int.
+ 1
Thanks