what is the difference between '!= 'and '!== ' [duplicate]
Possible Duplicates:
Is there a difference between !== and != in PHP? Javascript === vs == : Does it matter which “equal” operator I use?
In some cases when checking for not equal, I saw using != and in some places i saw !==. Is there any difference in that?
Example:
var x = 10;
if (x != 10) {
//..开发者_如何学Python.
}
and
if (x !== 10) {
//...
}
== compares only the value and converts between types to find an equality, === compares the types as well.
==means equal===means identical
1 is equal to "1", but not identical, because 1 is an integer and "1" is a string.
They are different in terms of strictness of comparison. !== compares variable types in addition to values.
!== will also check the type (int, string, etc.) while != doesn't.
For more information, see the PHP comparison operator documentation.
The !== is strict not equal: Difference between == and === in JavaScript
The difference is that
== (and !=) compare only the value,
=== (and !==) compare the value and the type.
For example
"1" == 1 returns true
"1" === 1 returns false, because one is a string and the other is an integer
Hope this helps. Cheers
加载中,请稍侯......
精彩评论