title: Getting Date and/or checking for it in JSON Object?
body: <p>I have a JSON object that can (is) storing a Date (and/or any other JS object) but I'm not sure how to get it out once it's in it. For example I have this sample code, but it's not working:</p>
  
  <pre><code>for(var key in value){
      if(value.hasOwnProperty(key)){
          if(typeof value[key] == 'object'){
              if(value[key].Date){
                  console.log('this is a date')
              }
              else{
                  console.log('not a date');
              }
          }
      }
  }
  </code></pre>
  
  <p>However, it just keeps return <code>not a date</code>. If i inspect the JSON object with Firebug or the Developer Console in WebKit i see <code>__proto__: Date</code> inside of the corresponding JSON item... so, how do I get it out or check for it?</p>
  
  <p>--EDIT--</p>
  
  <p>Here is what i see in the debugger:</p>
  
  <pre><code>Object
  -&gt;isADate: Fri Nov 26 2010 20:30:57 GMT-0800 (Pacific Standard Time)
  ---&gt;__proto__: Date
  -&gt;notADate: "some string"
  ---&gt;__proto__: Object
  </code></pre>
  
  <p>And here is the JSON im creating:</p>
  
  <pre><code>var dateStorage = new storageLocker('date-test');
  dateStorage.save({'isADate':new Date(),'notADate':'some string'});
  </code></pre>
  
  <p>Here is the code for this part of my script (http://github.com/oscargodson/storagelocker)</p>
  
  <pre><code>storageLocker.prototype.save = function(value){
  var json = JSON.parse(localStorage.getItem(this.catalog));
  if(json == null){json = {};}
  for(var key in value){
      if(value.hasOwnProperty(key)){
          json[key] = value[key];
          console.log(value[key].Date);
          if(typeof value[key] == 'object'){
              if(value[key].Date){
                  console.log('this is a date')
              }
              else{
                  console.log('not a date');
              }
          }
      }
  }
  localStorage.setItem(this.catalog,JSON.stringify(json));
  return this;
  }
  </code></pre>
  
  <p>Thanks a lot! Hope this helps out more!</p>