Why Date() has different type from new Date() in JavaScript? -
when run in console
typeof new date()
i object
. if evaluate
typeof date()
i string
. why?
from the mdn:
note: javascript date objects can instantiated calling javascript date constructor: calling regular function (i.e. without new operator) return string rather date object; unlike other javascript object types, javascript date objects have no literal syntax.
Comments
Post a Comment