title: Why is 'new Promise(...)' returning 'undefined'?
body: <p>It seems that if the 'resolve' function is not referenced in the function that is used to create a promise, then the promise is undefined. In the code below, ...</p>
  
  <pre><code>var count = 0;
  var limit = 3;
  //
  var thePromise;
  function timeout(_count) {
      thePromise.resolve(_count);
  }
  function sendMessage() {
      return new Promise(function(resolve, reject) {
          if (++count &gt; limit) {
              reject({'Limit Exceeded': count});
          }
          else {
  // With this line in place, the return value from this function
  // (expected to be a promise) is undefined
              setTimeout(timeout.bind(null, count), 1000);
  // If the line above is replaced by this, it works as expected
  //            setTimeout(/*timeout.bind(null, count)*/function (_count) {
  //                resolve(_count);
  //            }.bind(null, count), 1000);
          }
      });
  }
  
  function sendAnother(_count) {
      console.log('Resolved with count %j', _count);
      return sendMessage();
  }
  function detectError(_error) {
      console.log('Rejected with %s', JSON.stringify(_error));
      process.exit(1);
  }
  thePromise = sendMessage();
  thePromise = thePromise.then(function (_count) { return sendAnother(_count)}, function(_error) {detectError(_error)});
  </code></pre>
  
  <p>trying to do the resolve outside of the function that creates the promise, results in:</p>
  
  <pre><code>node-promises.js:6
      thePromise.resolve(_count);
                 ^
  TypeError: undefined is not a function
      at timeout (node-promises.js:6:16)
      at Timer.listOnTimeout (timers.js:110:15)
  </code></pre>
  
  <p>But if line 16 is commented out and lines 18-20 are uncommented, the output is:</p>
  
  <pre><code>Resolved with count 1
  </code></pre>
  
  <p>.. which is what I expected. What am I missing? This is using nodejs v0.12.2 on Windows 7, if that makes any difference.</p>