Lodash——flip 方法



語法

_.flip(func)

建立一個使用相反引數呼叫 func 的函式。

引數

  • func (函式) − 為其翻轉引數的函式。

輸出

  • (函式) − 返回新的翻轉函式。

示例

var _ = require('lodash');
var flipped = _.flip(function() {
   return _.toArray(arguments);
});
 
console.log(flipped(1, 2, 3, 4));

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

命令

\>node tester.js

輸出

[ 4, 3, 2, 1 ]
lodash_function.htm
廣告
© . All rights reserved.