# new-array

> create a new array filled with a value, or zero

Latest version **1.0.0** (published 2015-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install new-array
pnpm add new-array
yarn add new-array
bun add new-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-06-01 |
| First published | 2015-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | dense, array, filled, value, zero, zeroes, arrays, create, fill |

## Links

- npm: https://www.npmjs.com/package/new-array
- Repository: https://github.com/mattdesl/new-array
- Issues: https://github.com/mattdesl/new-array/issues
- npm.io page: https://npm.io/package/new-array

## Recent versions

- 1.0.0 (latest) — 2015-06-01

## README

# new-array

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

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

```js
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](https://nodei.co/npm/new-array.png)](https://www.npmjs.com/package/new-array)

#### `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

- [array-range](https://www.npmjs.com/package/array-range)

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/new-array/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/new-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
