Lodash - ary 方法
語法
_.ary(func, [n=func.length])
建立一個函式,呼叫 func,最多有 n 個引數,忽略任何其他引數。
引數
func (函式) − 要為其限制引數的函式。
[n=func.length] (數字) − 值約束。
輸出
(函式) − 返回新的限制函式。
示例
var _ = require('lodash');
var result = _.map(['6', '8', '10'], _.ary(parseInt, 1));
console.log(result);
將上述程式另存為 tester.js。執行以下命令來執行此程式。
命令
\>node tester.js
輸出
[ 6, 8, 10 ]
lodash_function.htm
廣告