Skip to content
Advertisement

Function take as an argument other function and few other arguments. Bind arguments to nested function and return recieved function

function bindFunction(fn, ...array) {
    let args = Array.from(arguments);
    function F() {
        return args;
    }
    return F.bind(bindFunction);
}

nested function, which outer function takes as a first parameter, must to bind other parameters to nested function and return them

Advertisement

Answer

I think this is what you are looking for.

function bindFunction(fn, ...array) {
  return fn.bind(null, ...array);
}
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement