On Jul 22, 8:15 pm, "Rob Desbois" <[EMAIL PROTECTED]> wrote: > Stephan, > The only time that == or != should be used (IMO anyway) is when you > explicitly *want* type conversion to take place. Otherwise, it's safest (and > faster) to use === or !==
The way i've always understood it (perhaps incorrectly) is that === and !== perform reference equality tests, such that ((new String("foo")) !== (new String("foo"))). A quick test shows: [EMAIL PROTECTED]:~$ SpiderApe -e "print( (new String('foo') === new String('foo')))" false And yet: [EMAIL PROTECTED]:~$ SpiderApe -e "print('foo' === 'foo')" true Weird. (SpiderApe is simply an interpreter built on the SpiderMonkey engine - http://SpiderApe.sf.net) Given that, it's hard to predict how (typeof SomeUndefinedThing === "undefined") *should* behave, because we can show that String objects and string literals are treated differently by ===, and we don't know (philosophically speaking) which type of string typeof will return. That said... [EMAIL PROTECTED]:~$ SpiderApe -e "print(typeof NonExistent === 'undefined')" true Hmmm. :/