5

Possible Duplicate:
Why does Chrome Dev Tool show a dates __proto__ as Invalid Date?

I get a weird message when I look up the prototype of the Date object:

Date.prototype; // Invalid Date

This is strange; why am I not getting the object from the prototype of Date as expected? Furthermore, the message that it returns is a string, but typeof(Date.prototype) returns "object". I also find that peculiar. Why am I getting this output?

Community
  • 1
  • 1
David G
  • 94,763
  • 41
  • 167
  • 253
  • How are you _"getting"_ the value of `Date.prototype`? Are you doing an implicit `toString` conversion? – Halcyon Jan 29 '13 at 17:17
  • @FritsvanCampen I'm simply logging it to the console. – David G Jan 29 '13 at 17:18
  • @FritsvanCampen Did you try it? If you `alert` it, you get "Invalid Date", if you `console.log` it, you get `Date {Invalid Date}` – Ian Jan 29 '13 at 17:18
  • 1
    In that case: http://stackoverflow.com/questions/9725299/why-does-chrome-dev-tool-show-a-dates-proto-as-invalid-date – Halcyon Jan 29 '13 at 17:19
  • I'm using Chrome, and in Chrome it said "Invalid Date". When I alert it, it says also "Invalid Date". I guess it varies from browser to browser – David G Jan 29 '13 at 17:20
  • `Date.prototype.toString()` is called in this case. – dfsq Jan 29 '13 at 17:25
  • What it shows when you alert it is (afaik) always the result of calling `toString` on it. What you see in the console depends on how fancy the browser maker got in his console features. @Antony `NaN` is the internal value of the date object, which is returned by `valueOf`. – Stijn de Witt Oct 29 '15 at 08:41

1 Answers1

3

15.9.5 Properties of the Date Prototype Object

The Date prototype object is itself a Date object (its [[Class]] is "Date") whose [[PrimitiveValue]] is NaN.

NaN is what's happening

Community
  • 1
  • 1
Joe
  • 80,724
  • 18
  • 127
  • 145