bhylu.com

Advertisements

Function this

A normal function receives this according to its call. Call can supply the receiver explicitly.

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

function label() { return this.name; }
console.log(label.call({name: "Mira"}));

What happens

The function reads Mira from the supplied receiver.