Status: New
Owner: ----
New issue 1356 by [email protected]: Date.now() == new Date should return
false
http://code.google.com/p/v8/issues/detail?id=1356
Chrome Version: 11.0.696.57
V8 Version: 3.1.8.12
Other engines tested:
JavascriptCore (Safari): OK
SpiderMonkey (Firefox): OK
What steps will reproduce the problem?
1. new Date == Date.now() -> false
2. Date.now() == new Date -> ???
What is the expected result?
false
What happens instead?
true!
I read through the relevant portions of the ECMAScript specification and
determined that the correct behavior is to return false for both of the
above statements.
When an object is compared for abstract equality (==) to a number,
regardless of order, the internal ToPrimitive(object) is called and
compared to the number. ToPrimitive returns the [[DefaultValue]] for the
object, given an optional preferred type. No preferred type hint is
provided when computing abstract equality, so the internal [[DefaultValue]]
method defaults to a number for all objects, _except_ Date objects (this is
bizarre, but the spec explicitly states this). This exception implies that
the above two equality tests should both return false, instead of true.
The corresponding Chromium bug is: http://crbug.com/81143
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev