💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## partial + [link](./partial "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L8980 "View in source.") + [npm](https://www.npmjs.com/package/lodash.partial "See the npm package.") ``` _.partial(func, [partials]) ``` 创建一个函数。 该函数调用 func,并传入预设的参数。 这个方法类似 `_.bind`,除了它不会绑定 `this`。 这个 `_.partial.placeholder` 的值,默认是以 `_` 作为附加部分参数的占位符。 **注意:** 这个方法不会设置 "length" 到函数上。 ### 参数 1. func (Function) 需要预设的函数 2. [partials] (...*) 预设的参数 ### 返回值 (Function) 返回预设参数的函数 ### 示例 ``` var greet = function(greeting, name) { return greeting + ' ' + name; }; var sayHelloTo = _.partial(greet, 'hello'); sayHelloTo('fred'); // => 'hello fred' // 使用了占位符 var greetFred = _.partial(greet, _, 'fred'); greetFred('hi'); // => 'hi fred' ```