Skip to content

mattdesl/new-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

new-array

stable

Creates a new dense array with the given size, optionally filled with a specified value.

var array = require('new-array')

array(2)
// > [ undefined, undefined ]

array(4, 0)
// > [ 0, 0, 0, 0 ]

array()
// > []

array(2).map((x, i) => i)
// > [0, 1]

Primarily motivated by the fact that new Array(n) produces an array of holes that does not play well with methods like Array#map().

Usage

NPM

arr = newArray(n[, value])

Returns a new dense array with length n (default 0), where each element is set to value (or undefined).

See Also

License

MIT, see LICENSE.md for details.

About

create a new array filled with a value, or zero

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published