4.17.11
3.10.1
2.4.2
1.3.1
_.rest(func, [start=func.length-1])
Creates a function that invokes func
with the this
binding of the
created function and arguments from start
and beyond provided as
an array.
Note: This method is based on the
rest parameter.
Since
4.0.0
Arguments
argument
func
[start=func.length-1]
type
Function
number
description
The function to apply a rest parameter to.
The start position of the rest parameter.
Returns
(array)
Example
var say = _.rest(function (
what,
names
) {
return (
what +
" " +
_.initial(names).join(", ") +
(_.size(names) > 1 ? ", & " : "") +
_.last(names)
);
});
say(
"hello",
"fred",
"barney",
"pebbles"
);
// => 'hello fred, barney, & pebbles'
var say = _.rest(function (what, names) {
return (
what +
" " +
_.initial(names).join(", ") +
(_.size(names) > 1 ? ", & " : "") +
_.last(names)
);
});
say("hello", "fred", "barney", "pebbles");
// => 'hello fred, barney, & pebbles'