JavaScript: Reflect.apply

By Xah Lee. Date: . Last updated: .

New in JS2015.

Reflect.apply(f, thisBinding, argList)
Call f with this Binding of thisBinding, and with arguments of elements in argList. Return the result. argList is array or Array-Like Object.
function f(a, b) {
  return a + b;
}
console.log(Reflect.apply(f, null, [1, 2]) === 3);

Here is example with thisBinding:

// example of Reflect.apply with thisBinding argument

function ff(a, b) {
  this.k1 = a;
  this.k2 = b;
}

const jj = {};

Reflect.apply(ff, jj, [3, 4]);

console.log(jj.k1 === 3);
console.log(jj.k2 === 4);

JavaScript: Apply Function

BUY
ΣJS
JavaScript in Depth

JS Obj Reference

Reflect