I've seen Reflect function few times while researching through the nodejs source code in events.js module. And can't find definition of it.
Can anybody explain me what this function does?
I've seen Reflect function few times while researching through the nodejs source code in events.js module. And can't find definition of it.
Can anybody explain me what this function does?
Reflect is a new ES6 built-in object.
Reflect.apply(...) will execute a function with a list of passed arguments.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply
Code sample
function sum(a, b) {
return a + b
}
const result = Reflect.apply(sum, undefined, [1, 2])
console.log(result)
// Same to
const result2 = sum.apply(undefined, [1, 2])
console.log(result2)