PDA

View Full Version : Override Model.isEqual()



ulrich.b
13 Apr 2012, 3:06 AM
My model class contains an array field. My problem is that, the standard Model-class doesn't recognize a set()-call with the same value, because the isEqual()-Method just uses the === operator.

Is it a good idea to overwrite the isEqual()-method? In the documentation it's marked with @private. What exactly does this annotation mean?

tvanzoelen
13 Apr 2012, 3:45 AM
I think your can override it for that specific model. But === does type comparison, isn't is possible to cast the input in the correct type?

Private means very often: 'not in the docs'. So you are not sure the function is still there with the next release. But this one I think you can override, no problem.

ulrich.b
13 Apr 2012, 4:14 AM
Many thanks for your answer.


But === does type comparison, isn't is possible to cast the input in the correct type?

Thats not possible, because the JavaScript === operator works just for scalar values, and I have an array (i.e. the expression [] === [] or {}==={} both return false).