bhylu.com

Advertisements

Object this

This depends on how a normal function is called. Calling a method through its object supplies that receiver.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const member = {
  name: "Mira",
  label() { return this.name; }
};
console.log(member.label());

What happens

The method reads Mira from its receiver.