On Jul 23, 11:27 am, "Rob Desbois" <[EMAIL PROTECTED]> wrote:
> What is this definition of the === operator you are referring to? I'm
> unaware of it having ever been defined as a reference comparison, and having
> read the relevant part of the ECMA Script specification yesterday I'm
> certain it isn't.

The "reference equality" was something i (mis?)remembered from prior
reading (some years ago). As it turns out, i was thinking of PHP, not
JS:

http://us.php.net/operators.comparison

But in fact PHP's op=== is also not "reference equality", but is
essentially: (LHS == RHS) && (typeof LHS == typeof RHS).

> > [EMAIL PROTECTED]:~$ SpiderApe -e "a=function(){return 'abc'[0];};
> > print(a() === 'a')"
> > true
>
> That proves it isn't a by-reference comparison.

Right.

> It is however the case that === is a safer comparison for a lot of
> situations. Allowing type conversions to take place means that you may get
> unexpected results, I have come across a situation where this happened
> before and so use the strict (in)equality operators now to avoid problems in
> future. If I want type conversion I make it explicit.

It's nice to finally get clarification on exactly what === is good
for. Thanks for clearing that up for me.

:)

Reply via email to