Files
lodash/constant.js
John-David Dalton 8c26e6fd4c Bump to v4.0.0.
2016-01-13 01:10:19 -08:00

27 lines
504 B
JavaScript

define([], function() {
/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new function.
* @example
*
* var object = { 'user': 'fred' };
* var getter = _.constant(object);
*
* getter() === object;
* // => true
*/
function constant(value) {
return function() {
return value;
};
}
return constant;
});