JS: Reflect.apply

By Xah Lee. Date: . Last updated: .

(new in JS: ECMAScript 2015)

Reflect.apply(f, thisBinding, argArray)
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