title: Difference between Q.defer() & Promise()
body: <p>I'm trying to understand why following code is behaving differently with Q.defer() and Promise()</p>
  
  <blockquote>
    <p><strong>Case 1</strong> : When I'm using Q.defer()</p>
  </blockquote>
  
  <pre><code>getDocument(id)
  .then(function (response) {
     console.log('in first then')
     return 'from two';
  }).then(function (response) {
     console.log(response)
  });
  
  var getDocument=function(){
    var b = Q.defer();
      b.resolve('from getDocument'); // here will do some async operation..this is just an example
    return b.promise;
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>in first then
  undefined
  </code></pre>
  
  <blockquote>
    <p><strong>Case 2</strong>: using Promise()</p>
  </blockquote>
  
  <pre><code>getDocument(id)
  .then(function (response) {
     console.log('in first then')
     return 'from two';
  }).then(function (response) {
     console.log(response)
  });
  
  var getDocument=function(){
    return Promise.resolve('from getDocument');
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>in first then        
  from two
  </code></pre>
  
  <blockquote>
    <p><strong>Question</strong></p>
  </blockquote>
  
  <ol>
  <li>Why there is a difference in output?</li>
  <li>I know that Q.defer is an anti-pattern but then how to choose when to use what?</li>
  </ol>