bhylu.com

Advertisements

Function Call

Call invokes a function with an explicit receiver followed by individual arguments.

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 total(extra) { return this.base + extra; }
console.log(total.call({base: 5}, 3));

What happens

The receiver supplies 5 and the argument adds 3, giving 8.