title: In jQuery, how does .state() determine whether a promise is pending, resolved or rejected
body: <p>I don't understand what determines state of a promise object. What causes an object or function to have a state of "pending", while the $(".selector") to have state of "resolved". </p>
  
  <p>Code as follows:</p>
  
  <pre><code>var obj = { prop: "value" };
  
  var deferred = new $.Deferred();
  var promiseObj1 = deferred.promise(obj);
  var promiseObj2 = $(".selector").promise();
  
  console.log(promiseObj1.state());    // "pending"
  console.log(promiseObj2.state());    // "resolved"
  </code></pre>