I want to define a JavaScript class, Foo.
Foo = function(value){
this.value = value;
};
I will create "instances" of my Foo:
foo1 = new Foo(1);
foo2 = new Foo(1);
and I want my instances of Foo to be comparable with each other using the standard == equality operator:
foo1 == foo2; // this should be true
I can not find a way to do this. I thought I was on to something with the valueOf()
function, but this is only useful when one side of the comparison is a primitive, not as above where both are of type object.
Have I missed something really simple akin to Ruby's
def ==(obj); end