Can insert an array or a single element. Negative indices count backwards from the end of the array.
Non-integer or out of bounds indices return the array unchanged. If index equals the length of the array, then elems will be appended to the end.
index
elems
import * as A from "flurp/array";const insertOne = A.insert(2, 10);insertOne([0, 1, 2, 3, 4]); // [0, 1, 10, 2, 3, 4]const insertMulti = A.insert(2, [10, 11, 12]);insertMulti([0, 1, 2, 3, 4]); // [0, 1, 10, 11, 12, 2, 3, 4]
Can insert an array or a single element. Negative indices count backwards from the end of the array.
Remarks
Non-integer or out of bounds indices return the array unchanged. If
index
equals the length of the array, thenelems
will be appended to the end.Example