=== means definately, most positively, no questions asked, equal to.
Now for the proper meanings:
Equal (==)
Returns true if the operands are equal. If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison examples
3 == var1
"3" == var1
3 == '3'
Strict equal (===)
Returns true if the operands are equal and of the same type. example
3 === var1
Originally posted by JAVAEOC oh ok i get it but when would u need a === operator?
When, as already implied, you want strict equality. The variables on each side of the operator must have equal values and of the same data type. For example, with your normal equality operator, this would return true:
Code:
'3' == 3;
This is because it merely checks to see if the two values are equal to each other — it doesn't care about the data type. However, when you use the strict equality operator in the same situation:
Code:
'3' === 3;
It will return false simply because the first is of the string data type, and the second is of the number data type.
Moderator @ WebDeveloper.com
Mentor @ WebXpertz.net
Comment