constant source npm

_.constant(value)

Creates a function that returns value.

Arguments

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