Lodash - flip 方法

语法

_.flip(func)

创建一个函数,该函数使用反转的参数调用 func。

参数

  • func (Function) − 要翻转参数的函数。

输出

  • (Function) − 返回新的翻转函数。

示例

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.html