Promise callbacks returning promises
<p>With regard to these great two sources: <a href="https://github.com/nzakas/understandinges6/blob/master/manuscript/11-Promises.md#returning-promises-in-promise-chains">NZakas - Returning Promises in Promise Chains</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">MDN Promises</a>, I would like to ask the following:</p>

<p>Each time that we return a value from a promise fulfillment handler, how is that value passed to the new promise returned from that same handler?</p>

<p>For instance,</p>

<pre><code>let p1 = new Promise(function(resolve, reject) {
    resolve(42);
});

let p2 = new Promise(function(resolve, reject) {
    resolve(43);
});

let p3 = p1.then(function(value) {
    // first fulfillment handler
    console.log(value);     // 42
    return p2;
});

p3.then(function(value) {
    // second fulfillment handler
    console.log(value);     // 43
});
</code></pre>

<p>In this example, <code>p2</code> is a promise. <code>p3</code> is also a promise originating from <code>p1</code>'s fulfillment handler. However <code>p2 !== p3</code>. Instead <code>p2</code> somehow magically resolves to <code>43</code> (how?) and that value is then passed to <code>p3</code>'s fulfillment handler. Even the sentence here is confusing.</p>

<p>Could you please explain to me what exactly is going on here? I am totally confused over this concept.</p>