What is a receiver in JavaScript?
<p>I am reading <a href="https://github.com/getify/You-Dont-Know-JS/tree/cc82d7c8f4872ceee87a5c3b193ee846c6ab0ecc/es6%20%26%20beyond" rel="nofollow noreferrer">You Don't Know JS: ES6 &amp; Beyond</a> and found some confused wording like:</p>
<blockquote>
<p>We declare a <code>get(..)</code> handler as a named method on the handler object (second argument to <code>Proxy(..)</code>), which receives a reference to the target object (<code>obj</code>), the key property name (<code>&quot;a&quot;</code>), and the self/receiver/proxy (<code>pobj</code>).</p>
</blockquote>
<p>My question is, what does &quot;receiver&quot; mean above and where does its name come from?</p>
<p>It seems like if I have an object &quot;a&quot; with a member function &quot;jump&quot;:</p>
<pre><code>var a = { jump: function() { console.log('jump!'); } };
</code></pre>
<p>If I run <code>a.jump();</code> then &quot;a&quot; is the receiver.</p>
<p>Is that how it works?</p>
<p>For people who read the same book: when you come to the <a href="https://github.com/getify/You-Dont-Know-JS/blob/cc82d7c8f4872ceee87a5c3b193ee846c6ab0ecc/es6%20%26%20beyond/ch7.md#proxy-first-proxy-last" rel="nofollow noreferrer">Proxy First, Proxy Last</a> section, you can add one line in the code to get a more clear picture about the context in the &quot;get&quot; trap:</p>
<pre><code>var handlers = {
    get(target, key, context) {
        console.log(greeter === context); //true, this line added
        return function() {
            context.speak(key + &quot;!&quot;);
        };
    }
},
catchall = new Proxy({}, handlers),
var greeter = {
    speak(who = &quot;someone&quot;) {
        console.log(&quot;hello&quot;, who);
    }
};

// setup `greeter` to fall back to `catchall`
Object.setPrototypeOf(greeter, catchall);

greeter.speak();                // hello someone
greeter.speak(&quot;world&quot;);       // hello world

greeter.everyone();             // hello everyone!
</code></pre>
<p>As you can see, thanks to the naming of the third argument of the &quot;get&quot; trap above, &quot;context&quot;, the receiver can vary according to lexical code -- <code>greeter.everyone();</code>. Please refer to Oriol's very detailed answer below for a better understanding.</p>