Skip to content

ary

js
_.ary(func, [n=func.length])

创建一个调用 func 的函数,最多带有 n 个参数,忽略任何其他参数。

¥Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.

新增于

¥Since

3.0.0

参数

¥Arguments

  1. func (函数):限制参数的函数。

    ¥func (Function): The function to cap arguments for.

  2. [n=func.length] (数值):元数上限。

    ¥[n=func.length] (number): The arity cap.

返回

¥Returns

(函数):返回新的上限函数。

¥(Function): Returns the new capped function.

示例

¥Example

js
_.map(['6', '8', '10'], _.ary(parseInt, 1));
// => [6, 8, 10]

Lodash v4.17 中文网 - 粤ICP备13048890号