array-insert

Return a new array with a inserted item at index.

Usage no npm install needed!

<script type="module">
  import arrayInsert from 'https://cdn.skypack.dev/array-insert';
</script>

README

array-insert Build Status

Return a new array with a inserted item at index

Install

$ npm install --save array-insert

Usage

var arrayInsert = require('array-insert');

arrayInsert((arrayInsert([1, 2, 4], 2, 3)));
//=> [1, 2, 3, 4]

API

arrayInsert(arr, pos, item)

arr

Required
Type: array

[1, 2, 3]

pos

Required
Type: number

2

item

Required
Type: any

4

License

MIT © Ulrik Augustsson