Lodash教程

Lodash spread method

语法

_.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.

参数

func (Function) − The function to spread arguments over. [start=0] (number) − The start position of the spread.

输出

(Function) − Returns the new function.

实例

var _ = require('lodash');
var say = _.spread(function(who, what) {
   return who + ' says ' + what;
});
console.log(say(['Joe', 'Hi']));
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

Joe says Hi
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4