underscoreに詳しくないので、勉強半分でソースコードを読む。
利用するバージョン
constantとは
underscorejs.orgのconstant
こんな説明。
_.constant(value)
Creates a function that returns the same value that is used as the argument of _.constant.
var stooge = {name: 'moe'};
stooge === _.constant(stooge)();
=> true
_.constantのargumentに使われているvalueとおなじ値を返す関数を作成します。
underscore.constant
コード的にはこのあたり。
// Predicate-generating functions. Often useful outside of Underscore.
_.constant = function(value) {
return function() {
return value;
};
};
valueを返す関数を返り値として返す