- Lodash チュートリアル
- Lodash - ホーム
- Lodash - 概要
- Lodash - 環境のセットアップ
- Lodash - 配列
- Lodash - コレクション
- Lodash - 日付
- Lodash - 関數
- Lodash - 言語
- Lodash - 數學
- Lodash - 數字
- Lodash - オブジェクト
- Lodash - シーケンス
- Lodash - 文字列
- Lodash - ユーティリティ
- Lodash - プロパティ
- Lodash - メソッド
- Lodash の役立つリソース
- Lodash - クイックガイド
- Lodash - 役立つリソース
- Lodash - ディスカッション
Lodash - カレーメソッド
構文
_.curry(func, [arity=func.length])
引數を渡して呼び出し、関數の結果を返す func 関數を作成し、少なくとも arity 個の引數が提供されている場合は結果を返し、それ以外は他の殘りの func 引數を渡す関數を返すなどして呼び出します。func.length が十分でない場合は、func のアリティを指定できます。
引數
func (関數) − カレーをかける関數。
[arity=func.length] (數字) − func のアリティ。
出力
(関數) − 新しいカレー関數。
例
var _ = require('lodash');
var getArray = function(a, b, c) {
return [a, b, c];
};
var curried = _.curry(getArray);
console.log(curried(1)(2)(3));
console.log(curried(1, 2)(3));
console.log(curried(1, 2, 3));
上記のプログラムを tester.js に儲存します。このプログラムを実行するには、次のコマンドを実行します。
コマンド
\>node tester.js
出力
[ 1, 2, 3 ] [ 1, 2, 3 ] [ 1, 2, 3 ]
lodash_function.htm
広告