Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

new-array

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

new-array

create a new array filled with a value, or zero

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-59.97%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 01 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc