4.17.11
3.10.1
2.4.2
1.3.1

_.rearg(func, indexes)

Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.

Since

3.0.0

Arguments

argument
func
indexes
type
Function
...(number|number[])
description
The function to rearrange arguments for.
The arranged argument indexes.

Returns

(array)

Example

var rearged = _.rearg(
  function (a, b, c) {
    return [a, b, c];
  },
  [2, 0, 1]
);

rearged("b", "c", "a");
// => ['a', 'b', 'c']
var rearged = _.rearg(
  function (a, b, c) {
    return [a, b, c];
  },
  [2, 0, 1]
);

rearged("b", "c", "a");
// => ['a', 'b', 'c']