This is expected: When comparing two objects like Date with <, they are converted into primitive values (numbers) first. This ToPrimitive-conversion takes most of the time when comparing two Date objects. Comparing the result of getTime() on the other hand is just a comparison of two numbers which is way more efficient.
2012/10/5 Matthew Caruana Galizia <[email protected]> > One of my colleagues wrote a test > <http://jsperf.com/date-comparison-test>that shows that comparing two Date > objects is ~95% slower than comparing > against the result of getTime. Why is this so? > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
