I am having a lot of confusion about the Date keyword in javascript. The MDN article, in it's second line, states that Date
is an object:
Date
objects are based on a...
But typeof Date
returns "function"
. Second thing is Date()
-- with closed brackets -- should be a function because anything of type foo()
is a function as per Douglas Crockford's book's chapter Grammar. Surprisingly enough, typeof Date()
returns "string"
. Now if Date()
is not a function then what is new Date()
? A string constructor? Precisely my questions are:
- What is
Date
? And how is it defined in javascript itself? - What is
Date()
? How is it different fromDate
? How is it defined in javascript itself? Why is it not a function? - What is
new Date()
? IfDate()
is a string then how can it act as constructor? - If we can instantiate
new Date()
, e.g. likenew Date("October 13, 2014 11:13:00")
then why can't we instantiate the original functionDate()
similarly asDate("October 13, 2014 11:13:00")
?