Reputation: 2922
I'm creating a new date object in Javascript and it throws Invalid Date error in IE11.
It runs fine on Chrome and Firefox though. Any idea what can be wrong?
new Date()
[date] Thu Sep 22 2016 12:24:33 GMT+0530 (India Standard Time)[date] Thu Sep 22 2016 12:24:33 GMT+0530 (India Standard Time)
[functions]
__proto__[date] Invalid Date
screenshot: http://screencast.com/t/hN4Kt8FEwdXu
Upvotes: 0
Views: 1805
Reputation: 7634
Where do you see that it throws? The console displays a Date instance. The __proto__
property of this instance is an invalid date, but you should not care about that at all, it's part of the internal implementation.
Try new Date().toString()
, you should get a valid string representation of your date, which means that all is fine.
Upvotes: 1
Reputation: 15639
It actually returns a date object where as the __proto__
(prototype) alone says "Invalid Date" which is as per the ES5 Date specification which goes like this,
The Date prototype object is itself a Date object (its [[Class]] is "Date") whose [[PrimitiveValue]] is NaN.
Source URL : http://es5.github.io/#x15.9.5
Hope this helps
Upvotes: 0