+ 1
= is used to present variable.'Equal to' by '===' Why is 'equal to' presented with only two '=='?
7 Antworten
+ 4
x=3, it mean x has value 3. Hence,x equals 3.
but for, x==3 it will check 'is the value of x 3?' So,one(=)is for defining a value & other (==) for comparing. While other (===) compares for Type as well as value a variable holding.
Example:
x=3; y=3; Both are of type integer along with their same value,which is '3'. This will return 'true'
+ 1
=== is identical (value and type), == is equivalent, i.e. 1 == true, but 1!== true
+ 1
identical to check type of var
+ 1
== Equal but may not be of same type.
=== Both equal and of same type.
+ 1
=(equal) is used for assigning a value to variable,
== operator will compare for equality after doing any necessary type conversions. The === operator will not do the conversion, so if two values are not the same type === will simply return false. It's this case where === will be faster, and may return a different result than ==. In all other cases performance will be the same.
+ 1
the = is used to assign values to variables, (a = 5)
this, ==, is used to compare values. the == would compare and return 'true' if the values being compared are the same. they could be of the same type or not.
that is: if a = 5
(a == 5) would return true
(a == '5') would also return true
the === is used to compare STRICTLY values of the same type: strings or integers
then: if a = 5
(a === 5) would return true: they are of the same type and identical values ( the number 5)
(a === '5') this time would return false, as they are of different data types(5--number five and a string--5)
0
=== means identical so 10 === "10" will return the boolean false. == means that it is equal, it doesn't what data type it is, so 10 == "10" will return the boolean true.