_.fill(array, value, [start=0], [end=array.length])
Fills elements of array
with value
from start
up to, but not including, end
.Note: This method mutates array
.
Since
3.2.0
Arguments
array
(Array): The array to fill.value
(*): The value to fillarray
with.[start=0]
(number): The start position.[end=array.length]
(number): The end position.
Returns
(Array): Returns array
.
Example
var array = [1, 2, 3];_.fill(array, 'a');console.log(array);// => ['a', 'a', 'a']_.fill(Array(3), 2);// => [2, 2, 2]_.fill([4, 6, 8, 10], '*', 1, 3);// => [4, '*', '*', 10]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .