title: JavaScript instanceof and moment.js
body: <p>I'm attempting to understand types in the JavaScript world. My page is using <a href="http://momentjs.com/">moment.js</a>. I have a function that sometimes returns a <code>moment()</code> and other times, returns a <code>string</code> (it's legacy code gone wild).</p>
  
  <p>My code kind of looks like this:</p>
  
  <pre><code>var now = getDate();
  if (now instanceof moment) {
    console.log('we have a moment.');
  } else {
    console.log('we have a string.');
  }
  
  
  function getDate() {
    var result = null;
    // Sometimes result will be a moment(), other times, result will be a string.
    result = moment();
    return result;
  }
  </code></pre>
  
  <p>When I execute the code above, I never get <code>we have a moment.</code>. Even if I manually make set <code>result = moment();</code>. Why is that? Am I misunderstanding <code>instanceof</code> or <code>moment</code>?</p>