Subj : Re: Date() == new Date() To : Celso Aguiar From : Brendan Eich Date : Wed Sep 08 2004 03:25 pm Celso Aguiar wrote: > Ecma wise, what's the expected return from the above, true or false? > I know 'Date()' called as a function returns a string, while 'new Date()' > returns an object. I also know Date.toString() is getting called (SM) > for 'new Date()' before the '==' equality operator is evaluated (to 'true'). > What's the expected return for Date() === new Date()? > Thanks for the attention! There is no well-defined result for eval("Date() == new Date()"), for one reason because there is a race condition: the new Date() could happen in a later second than the Date(), resulting in different strings. The result is undefined for another reason: ECMA-262 Edition 3 specifies that Date() return "a string representing the current time (UTC)" (15.9.2). ECMA-262 Ed. 3 also says that a Date object converts to a string whose contents are "implementation-dependent, but are intended to represent the Date in the current time zone in a convenient, human-readable form" (15.9.5.2). So even if there were no race condition, ECMA does not require to result of Date() to match the result of Date.prototype.toString(). /be .