Q:

Write a JavaScript program to create a function that invokes the provided function with its arguments arranged according to the specified indexes

0

 Write a JavaScript program to create a function that invokes the provided function with its arguments arranged according to the specified indexes.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i]));
var rearged = rearg(
  function(a, b, c) {
    return [a, b, c];
  },
  [2, 0, 1]
);
console.log(rearged('b', 'c', 'a'));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now