Arrays.replace()

Replace the item located at the specified index and return the result (a new array).

Usage

Hover over inputs/exits for more info.

var Arrays = require('machinepack-arrays');


// Replace the item located at the specified index and return the result (a new array).

Arrays.replace({

array: [ '*' ],

index: 1,

value: '*',

}).execSync();

Inputs

array required

The array where the new item should be inserted.

[ '*' ]
index required

The index of the item to replace.

1
value required

The new value to replace the old one with.

'*'

Exits

error

An unexpected error occurred.

notFound

The array does not have enough items for anything to exist at the specified index.

success

OK.

(varies based on provided inputs)