[ng-dhtml] comparing dojo.uri.Uri objects and dojo.xml.htmlUtil.insertCssFile bug (?)

Bob Ippolito bob at redivi.com
Fri Sep 2 17:42:06 CDT 2005

On Sep 2, 2005, at 2:42 PM, Tom Trenka wrote:

> Speaking *very* quickly here, and not having actually tested this  
> extensively (but having done some work in this area to try to see  
> if I can trick JS into some version of operator overloading)...I  
> *think* that it depends on what is returned from either .valueOf  
> or .toString, as opposed to comparing the object directly.
> It's interesting because you bring up a topic that I was about to  
> start hitting again pretty hard for other purposes...and maybe  
> should be tried?
> Anyways.  A quick look at some docs say this:
> Equality (==, !=)
> If the types of the two expressions are different, attempt to  
> convert them to string, number, or Boolean.
> NaN is not equal to anything including itself.
> Negative zero equals positive zero.
> null equals both null and undefined.
> Values are considered equal if they are identical strings,  
> numerically equivalent numbers, the same object, identical Boolean  
> values, or (if different types) they can be coerced into one of  
> these situations.

In other words, JavaScript's comparators are fucked up and brain  
damaged for dealing with anything but primitives.  Don't use them if  
you need more than ===, use something reliable and well-defined  
instead.  This is why MochiKit has a generic cmp(a, b) function.

If using == was a good idea, then built-in prototypes such as Array  
and Date would be meaningfully comparable; they're not.


More information about the NG-DHTML mailing list