主题
constant
js
_.constant(value)
创建一个返回 value
的函数。
¥Creates a function that returns value
.
新增于
¥Since
2.4.0
参数
¥Arguments
value
(*):要从新函数返回的值。¥
value
()*: The value to return from the new function.
返回
¥Returns
(函数):返回新的常量函数。
¥(Function): Returns the new constant function.
示例
¥Example
js
var objects = _.times(2, _.constant({ 'a': 1 }));
console.log(objects);
// => [{ 'a': 1 }, { 'a': 1 }]
console.log(objects[0] === objects[1]);
// => true