LLearnCode
Academy/javascript/The language beneath the syntax

intermediate · 23 minute study

Method calls choose a receiver

Passing an object method as a callback can lose its receiver. Understanding prototypes also makes classes less mysterious.

Loading progressEvidence grows with practice
Useful preparation · 1 prerequisite

Use this as a map, not a lock. If these ideas are familiar, continue.

First, build a mental model

For an ordinary function, this depends on how it is called. Objects delegate missing property lookups along a prototype chain. Class syntax organizes that model; it does not replace it.

  1. player.label() supplies player as the receiver.
  2. Extracting a method into a variable does not preserve the receiver.
  3. bind returns a function with a fixed this; an arrow captures lexical this.
  4. Prototype methods can be shared by instances instead of allocating the same function on each one.
Read the codejavascript · educational example
'use strict';
const player = { name: 'Mira', label() { return this.name; } };
const detached = player.label;
console.log(player.label());
try { console.log(detached()); } catch (error) { console.log(error.name); }
const bound = player.label.bind(player);
console.log(bound());
  1. Method call

    player is the receiver, so this.name is Mira.

  2. Detached call

    No object receiver is supplied. Strict mode gives undefined this.

  3. Bound call

    bind supplies player regardless of the later call site's receiver.

Production thinking

Take this beyond the example.

Use composition and plain functions when they make ownership clearer. Choose classes for useful state/behavior contracts, and be explicit at callback boundaries.

Sources and further reading

Your evidence

unseen is a local learning signal, not a credential or proof of production competence.

Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.

Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.

Next lesson · One event travels through a tree →