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

array-add-item

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-add-item

Add item to array

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

add item in array

XO code style

Just a simple function to add an item into an Array. Works well in both, the browser & node.

install

npm i -S array-add-item

and use it

import addItemInArray from 'array-add-item'
// OR
const addItemInArray = require('array-add-item')

const abcde = addItemInArray(['a', 'c', 'd', 'e'], 'b', 1)
console.log(abcde) // ['a', 'b', 'c', 'd', 'e']

behavior

  • addItemInArray is a pure function, it does not mutate the provided array.
  • item is added at the end if no position is provided or it is out of the range of the array (grater than arr.length or less than 0).
  • returns the array if the position provided is not a number or is a float number.

FAQ

Keywords

FAQs

Package last updated on 07 Sep 2016

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