4.17.11
3.10.1
2.4.2
1.3.1

_.spread(func, [start=0])

Creates a function that invokes func with the this binding of the create function and an array of arguments much like Function#apply.

Note: This method is based on the spread operator.

Since

3.2.0

Arguments

argument
func
[start=0]
type
Function
number
description
The function to spread arguments over.
The start position of the spread.

Returns

(array)

Example

var say = _.spread(function (
  who,
  what
) {
  return who + " says " + what;
});

say(["fred", "hello"]);
// => 'fred says hello'

var numbers = Promise.all([
  Promise.resolve(40),
  Promise.resolve(36),
]);

numbers.then(
  _.spread(function (x, y) {
    return x + y;
  })
);
// => a Promise of 76
var say = _.spread(function (who, what) {
  return who + " says " + what;
});

say(["fred", "hello"]);
// => 'fred says hello'

var numbers = Promise.all([Promise.resolve(40), Promise.resolve(36)]);

numbers.then(
  _.spread(function (x, y) {
    return x + y;
  })
);
// => a Promise of 76