Date() == new Date()

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!

Celso
0
celsoaguiar
9/8/2004 6:58:56 PM
netscape.mozilla.jseng 1530 articles. 0 followers. Follow

2 Replies
925 Views

Similar Articles

[PageSpeed] 30

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
0
Brendan
9/8/2004 9:25:01 PM
Brendan Eich wrote:
> Celso Aguiar wrote:
> 
>> What's the expected return for Date() === new Date()?


I forgot to answer this one: false, always, per ECMA-262 Edition 3, 
11.9.6, quote:

The comparison x === y, where x and y are values, produces true or 
false. Such a comparison is performed as follows:

1. If Type(x) is different from Type(y), return false.
2. If Type(x) is Undefined, return true.
3. If Type(x) is Null, return true.
4. If Type(x) is not Number, go to step 11.
5. If x is NaN, return false.
6. If y is NaN, return false.
7. If x is the same number value as y, return true.
8. If x is +0 and y is  0, return true.
9. If x is  0 and y is +0, return true.
10. Return false.
11. If Type(x) is String, then return true if x and y are exactly the 
same sequence of characters (same length and same characters in 
corresponding positions); otherwise, return false.
12. If Type(x) is Boolean, return true if x and y are both true or both 
false; otherwise, return false.
13. Return true if x and y refer to the same object or if they refer to 
objects joined to each other (section 13.1.2). Otherwise, return false.

/be
0
Brendan
9/8/2004 9:54:24 PM
Reply:

Similar Artilces:

Dates, Dates, Dates!
Hello all... I am in the process of building an appointment system, and I am trying to see if I can get some pointers on which way to go on this. The first version of this appointment system was very lo-tech, and it stored all of the possible dates/times in the database. Once a user booked an appointment, their information was logged to that date/time, and then that date/time would no longer show in the list of possible openings. This was great for a temporary fix, but with having to pre-populate all of the dates/times, the system would eventually have to be updated to continue on pa...

From Date and To Date
 In my application i have two textboxes.One for From date and the other one for To date.I need to check whether the From date is lesser than To Date..Date formats will be either(DD-MM-YYYY) or (DD/MM/YYYY).and i have used calendar extender for selecting dateI need the script code to do this...Thanks in advance See this thread: http://forums.asp.net/t/1346328.aspxMohsin Naeem"Please mark as answer if it helped you"  <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </...

from date to date
I am working on a form for livestock. one of the things in the form is a checkbox to let me know if they qualify or not. the second is I have a created record field entered into the database... now my question is I am doing a search on this and cant figure it out since i am new to all this...i have a query that selects the qualification checkbox (where qualify = 'true') then another query that selects the created record date... and the search is that I want to get the information in the livestock that are qualifyed (have the checkbox qualify = to 'true') between  one dat...

given a date plus a number of working dates, return the new date
Hello, I've been googling for this with not much luck.. I use Delphi 6. Is there any function that does this? The only way I can think is iterating and discarding the Saturdays and Sundays but I don't this this is a clever solution... function NewDate(ADate: TDateTime; Inc: integer): TDateTime; var DoW: integer; begin result := ADate; while Inc > 0 do begin result := result + 1; DoW := DayOfWeek(result); if (Dow <> 1) and (DoW <> 7) then Dec(Inc); end end; And by the other hand... what if I want to know how...

New Date::Discordian, Date::ICal
The new Date::Discordian module, just uploaded to CPAN, has just what everyone needs. You can now get the discordian date for dates outside of the Unix epoch. This is, of course, of great importance, since everyone needs to know that the Battle of Hastings was fought on Setting Orange (Mungoday), Chaos 5 YOLD 2232. Is it a coincidence that this was a holyday? I don't think so either! And, along the way, we finally got around to releasing a few new versions of Date::ICal, largely motivated by the need to fix some bugs in Date::Discordian. So you can mock Date::Discordian all you l...

convert date christian date to persian date
hi, I need to convert christain date that was produced in my Sql database to persian date like" دوشنبه 21 مرداد 1378" in a datalist.Could you recommend me any function.I use VisualStudio 2005 & VB. thanks in advance Sepid Take a read of http://www.codeproject.com/KB/database/PersianDateInSQLServer.aspx or maybe a javascript route like http://www.codeproject.com/KB/gadgets/PersianDateViewerGadge.aspx Hope it helpsRegardsJeremyIf this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.That way future readers will ...

How do order the list by date to show for new dates.
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>" SelectCommand="SELECT [Title], [URL], [Date] FROM [Article] ORDER BY [Date] DESC"></asp:SqlDataSource> <asp:Repeater id="myRepeaterUL" runat="server" DataSourceID="SqlDataSource1"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate&...

compare date to a date
I have in a where clause the following statement. SELECT "sales"."sale_date", "sales"."ling_no", "sales"."course_no", "sales"."product_no", "sales"."service_no", "sales"."quantity", "sales"."amount", "payment"."amount", "payment"."payment_form" FROM "payment", "sales" WHERE ( "sales".&...

the From date should be lesser than To Date
 In my application i have two textboxes.One for From date and the other one for To date.I need to check whether the From date is lesser than To Date..Date formats will be either(DD-MM-YYYY) or (DD/MM/YYYY).and i have used calendar extender for selecting dateI need the script code to do this...Thanks in advance DateTime.Compare(t1,t2); Value Type Condition Less than zero  t1 is earlier than t2. Zero t1 is the same as t2. Greater than zero t1 is later than t2. "Object reference not set to an instance of an object" from date :(i...

dates between date ranges
hi, i need 1 help regarding query, i have Startdate and Enddate using SELECT statement i need all the dates between these 2 dates, is it possible or i had to do it programatically, or i had insert data only please helpThanksParthvisit for some interesting articals at www.parthrawal.blogspot.comMark as Answer if it helps you  declare @temp table ( [date] datetime ) declare @startdate datetime,@enddate datetime set @startdate = getdate() -- here you can write a select stmt as "select startdate from tablename" set @enddate = getdate() + 10 -- here you can write a ...

No date in Date field
I have just installed thunderbird on my system. I migrated from outlook express. All the mail that was there before shows both the date and the time in the date field. However, all mail received by thunderbird only has a time stamp, no date. How do I correct this?? Thanks, Roger _Roger Bailey_ spoke thusly on 29/08/2006 10:09 PM: > I have just installed thunderbird on my system. I migrated from outlook > express. All the mail that was there before shows both the date and the > time in the date field. However, all mail received by thunderbird only has ...

calendar date span (date start : date end)
Hi! Can anyone help me with this? Say, I have these two textboxes. Date Start:        Date End:             What I wanted to do is to put dates on it using the calendar. My problem is I do not know what to do to keep the "Date Start" not way after the set "Date End", and for "Date End" not way before the set "Date Start".   example: Date Start: July 1, 2008              &nb...

date field = date
i made an news table and i made and option to add and update and delete news from it i need one thing that when someone try to add news the time that he insert the news will be in teh date field of the table and dont the costumer write it   hope that u understand me Hi, did you mean you want to add a column that get current date as its value automaticly? If so, you can do the following in Access2003: 1. add a column with 'Date/Time' data time 2. In the 'Field Properties'->'General' pannel, add a 'Default Value' for it, 3. In the 'Expression Builder', double cli...

search date TO date
Hii all...haii..im still beginner in asp.net..here i want to know how to create search date until date?here is my example:- Hi, I don't see your code------------------------if an answer, mark it so. Hi yanz_shi, As mentioned, we couldn't see your example. Please check the thread after you've created it so that we can help you better. Also, for searching between two dates, you could do it like this: select * from tab where dt between date1 and date2 Thanks.David QianMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark ...

Web resources about - Date() == new Date() - netscape.mozilla.jseng

Raj Date - Wikipedia, the free encyclopedia
... industry in 2009 to start the Cambridge Winter Center, a nonprofit think tank devoted to promoting the regulation of financial firms. Date joined ...

LCD Soundsystem promise more 2016 tour dates
photo: LCD Soundsystem at Terminal 5 in 2011 (more by Andrew St. Clair) We already knew that just five years after breaking up, LCD Soundsystem ...

John Oliver Reveals ‘Last Week Tonight’ 2016 Return Date In New Year’s Video
HBO ’s Last Week Tonight host John Oliver has some advice for keeping those New Year’s resolutions you’ve probably already broken. Lower your ...

Jennifer Lawrence Admits She Doesn't Meet Many Men She Wants to Date
Who needs a boyfriend when you're best friends with Amy Schumer, Emma Stone and Adele?

Sony: 35.9 million PS4 consoles sold to-date
Sony announced today that it has sold a total of 35.9 million PlayStation 4 consoles since its launch in November of 2013. The new sales figures ...

Oculus Rift preorders start in less than 48 hours, but price and ship date still a mystery
It’s been nearly four years since Oculus wrapped up the Kickstarter campaign for its virtual reality headset, the Rift. Today, the company announced ...

Court Date for Man Charged in Fatal Church Stabbing
Man charged in fatal stabbing of South Korean visitor at rural Maryland religious retreat

Mark Zuckerberg's Response To People Who Tell Girls To 'Date The Nerd'
Huffington Post Mark Zuckerberg's Response To People Who Tell Girls To 'Date The Nerd' Huffington Post On Sunday, Zuckerberg posted on Facebook ...

‘Sword Art Online’ Season 3 Release Date Delayed To 2016 Over Movie Video Or ‘SAO: Progressive’ Light ...
Predictions for the Sword Art Online Season 3 release date all seemed to point to late 2015, but since New Year’s Eve is upon us, it is quite ...

Jesy Nelson Shares Cute Photos From Dinner Date With Fiance Jake Roche
... Could Jesy Nelson and Jake Roche get any cuter? The 24-year-old Little Mix singer took to Instagram to share some adorable pics from her date ...

Resources last updated: 1/6/2016 4:00:48 AM