jskatas.org Continuously Learn JavaScript. Your Way.

Reflect: Reflect.apply()

Calls a target function with given scope and arguments.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

Reflect.apply calls a target function

  • it is a static method

the 1st parameter

  • is a callable, e.g. a function
  • passing it a non-callable throws a TypeError

the 2nd parameter

  • is the scope (or the this)

the 3rd parameter

  • must be an array (or array-like)
  • is an array of parameters passed to the call

example usages

  • simple function call
  • call a function on an array
  • pass in the this that the function to call needs


How this function is specified.
How the 3rd parameter gets processed, as an `CreateListFromArrayLike`.
The MDN docs for this function.
Announcement of this kata on twitter.