In my code, I have a function A
that accepts another function as an argument. Within function A
, I aim to run the given function with one specific parameter and the remaining parameters from the given function. Here's an example:
function t(g: number, p: any, b: any): void {
console.log(g)
console.log(p)
console.log(b)
}
function execute(fn: (t: number, ...args: any[]) => void) {
// However, I encountered an issue with this approach... I'm receiving the following error --- 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
const ar = fn.arguments.slice(1)
fn(3, ...ar)
}
execute(t)
Is there a way to effectively capture args
and execute it with fn
in strict mode?