Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Reflect.apply — call a function with explicit this and arguments

Reflect.apply calls a function with a supplied `this` value and arguments read from a supplied object. It returns the function's result without reading the function's `apply` property.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Reflect.apply(target, thisArgument, argumentsList)

Reflect.apply(target, thisArgument, argumentsList) calls target, supplying thisArgument as its this value and the elements of argumentsList as successive arguments. It returns the call's result; exceptions propagate. It does not create an instance or replace the new operator.

argumentsList must be an object, but it does not need to have a length property or any indexed properties. The method reads length, converts the value to a length, then reads the corresponding indexed properties. A missing length is treated as zero, so {}, for example, is accepted and supplies no arguments. You can also pass an array or an object like the one in the example. The method does not use the iteration protocol, so it does not expand the elements of a Set into arguments. Property reads can invoke getters.

A non-callable target or a non-object argumentsList causes a TypeError. Unlike Function.prototype.apply, an omitted argumentsList, null, or undefined does not mean an empty list — pass []. The method does not read target.apply, so it also works when that property has been shadowed.

Supplying thisArgument does not override the target function's rules: an arrow function keeps its lexical this, and a function bound through bind keeps its bound this. An ordinary strict-mode function receives the supplied value unchanged; outside strict mode, the usual this conversion rules apply.

Examples

function total(a, b) {
  "use strict";
  return this.base + a + b;
}

const receiver = { base: 10 };
const args = { 0: 2, 1: 3, length: 2 };
console.log(Reflect.apply(total, receiver, args));

Result

15

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources