_.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
func
(Function): The function to apply a rest parameter to.[start=func.length-1]
(number): The start position of the rest parameter.
Returns
(Function): Returns the new function.
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'
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .