Lodash - 一元方法



語法

_.unary(func)

建立一個函式,該函式最多接受一個引數,忽略其他所有引數。

引數

  • func (Function) − 要為其限制引數的函式。

輸出

  • (Function) − 返回新的限制函式。

示例

var _ = require('lodash');
console.log(_.map(['6', '8', '10'], _.unary(parseInt)));

將上述程式儲存在 tester.js 中。執行以下命令執行此程式。

命令

\>node tester.js

輸出

[ 6, 8, 10 ]
lodash_function.htm
廣告
© . All rights reserved.