javascript - How does angular.equals evaluate invalid date objects? -
i understand shouldn't using invalid date objects compare each other, purposes of understanding how , why angular.equal handles
angular.equals(new date(''), new date('')); //returns false, both objects null on other hand
angular.equals(null, null); //returns true what missing here? jsfiddle if feel need
if using angular <1.2.x see behavior. because .equals implementation checks equality of p1.gettime() , p2.gettime() in case nan , nan not nan. 1.2.x onwards has been changed there recursive check again on .equals , there condition:
if (o1 !== o1 && o2 !== o2) return true; // nan === nan which see value returning true in case.
else if (isdate(o1)) { if (!isdate(o2)) return false; return equals(o1.gettime(), o2.gettime()); //returns false } else if (isdate(o1)) { return isdate(o2) && o1.gettime() == o2.gettime(); //returns true }
Comments
Post a Comment