I don't think many actually use !== (and when you would want to use
it) and many sites that show usage of operators don't cover !== (but
do have ===).
3 != '3' false
3 !== '3'true
3 == '3' true
3 === '3'false
On Aug 1, 9:33 pm, Michael Geary [EMAIL PROTECTED] wrote:
I had a discussion on the use of the === and !== operators recently on this
list, my opinion was, and still is, that unless you explicitly WANT to allow
type conversion, you should be using these. Only use == and != if you really
want type conversion.
It's bitten me once, although I can't for the
!== and === are identity operators. It is a good idea to use them
instead of the equality operators (!= and ==) unless you know why you
would want to use equality (and the possible type coercion) over
identity. Probably the biggest gotcha with equality is with falsy
values (false, 0, undefined,
known about this for awhile but since we are on the topic... there
has to be some over head of using == and != does anyone know for
sure the impact of the overhead... and does it matter of the type
On Aug 2, 6:21 am, Ian Struble [EMAIL PROTECTED] wrote:
!== and === are identity
There's no overhead unless the types are different. From the ECMAScript
specification:
For the 'abstract equality comparison algorithm' (==) [11.9.3]
1. if Type(x) is different from Type(y), go to step 14.
For the 'strict equality comparison algorithm' (===) [11.9.3]
1. if Type(x) is different
That's an interesting find, Rob, thanks. But watch out. We're looking at the
ECMAScript standard, not running code. An actual implementation could have
different performance for the two operators and still conform to the spec.
It does seem unlikely that anyone would code == to be slower than ===
The triple equals is a comparison without type conversion. The following
should fix your code so that fn.apply() never runs with fn is null:
if (fnfn.apply(...)) break;
The first part checks if fn is non-null, if it is null or false or 0 or Nan
the second part fn.apply will never run and you
I...cannot figure how what the heck === is.
I see that Jake answered your question, but just for next time...
You may have tried a Google search for javascript === and been
disappointed to find it returned no useful results (because Google seems to
ignore the === in the search).
The key thing
Wow, that *is* funny. I must confess that I didn't actually look at the
search results!
_
From: Ganeshji Marwaha
funny, both w3schools and javascriotkit (top 2 results for the query
javascript+operators) doesnt seem to have an explanation for !==. ;-)
On 8/1/07, Michael Geary [EMAIL
funny, both w3schools and javascriotkit (top 2 results for the query
javascript+operators) doesnt seem to have an explanation for !==. ;-)
-GTG
On 8/1/07, Michael Geary [EMAIL PROTECTED] wrote:
I...cannot figure how what the heck === is.
I see that Jake answered your question, but just for
10 matches
Mail list logo