title: Understanding javascript promises; stacks and chaining
body: <p>I've been running into a couple of problems with javascript promises, particularly with stacked chains. </p>
  
  <p>Can anyone explain to me the difference (if there is any!) between these different implementations? </p>
  
  <p>IMPLEMENTATION 1</p>
  
  <pre><code>var serverSidePromiseChain;
  serverSidePromiseChain = async().then(function(response) {
      console.log('1', response);
      return response;
  }).then(function(response) {
      console.log('2', response);
      return true;
  }).then(function(response) {
      console.log('3', response); // response expected to be 'true'
      return async3();
  }).then(function(response) {
      console.log('4', response);
      return async4();
  })
  </code></pre>
  
  <p>IMPLEMENTATION 2</p>
  
  <pre><code>var serverSidePromiseChain;
  serverSidePromiseChain = async().then(function(response) {
      console.log('1', response);
      return response;
  });
  
  serverSidePromiseChain.then(function(response) {
      console.log('2', response);
      return true;
  })
  serverSidePromiseChain.then(function(response) {
      console.log('3', response); // response expected to be 'true'
      return async3();
  })
  serverSidePromiseChain.then(function(response) {
      console.log('4', response);
      return async4();
  })
  </code></pre>
  
  <p>IMPLEMENTATION 3</p>
  
  <pre><code>var serverSidePromiseChain;
  serverSidePromiseChain = async().then(function(response) {
      console.log('1', response);
      return response;
  });
  
  serverSidePromiseChain = serverSidePromiseChain.then(function(response) {
      console.log('2', response);
      return true;
  })
  serverSidePromiseChain = serverSidePromiseChain.then(function(response) {
      console.log('3', response); // response expected to be 'true'
      return async3();
  })
  serverSidePromiseChain = serverSidePromiseChain.then(function(response) {
      console.log('4', response);
      return async4();
  })
  </code></pre>
  
  <p>Does the fact that part of the chain returns a value ('true' in step 2) change the behavior? Do promises require all returned values to be async promises to keep behavior?</p>