title: Why does JSON.stringify() accept Date objects?
body: <p>At least in Firefox, you can stringify a Date object:</p>
  
  <pre><code>&gt;&gt;&gt; JSON.stringify({'now': new Date()})
  '{"now":"2012-04-23T18:44:05.600Z"}'
  </code></pre>
  
  <p>This works because (in Firefox) <code>Date</code> contains a <code>toJSON</code> method which is used by its JSON serializer. However, this is not part of the JSON standard so I wonder why this method exists or rather why the builtin JSON serializer checks for such a method. Since it's not standardized you cannot safely use it anyway without first testing if the builtin serializer understands it and otherwise use a custom one (such as <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js">json2.js</a>)</p>