Inserts the value(s) at the given position. If the index is equal or higher than the array length, the value(s) will be appended. If the index is less than 0, the value(s) will be prepended.
Note that the input array is being mutated.
12.1.0
lodash.pullAt
The mutated array.
const a = ["foo", "fizz"];insertAt(a, 1, "bar")// => ["foo", "bar", "fizz"]const b = ["foo", "fizz"];insertAt(b, 1, "bar", "bazz"))// => ["foo", "bar", "fizz", "bazz"]const c = ["foo", "fizz"];insertAt(c, 999, "bar"))// => ["foo", "fizz", "bar"]const d = ["foo", "fizz"];insertAt(d, -999, "bar"))// => ["bar", "foo", "fizz"]
Array to modify.
Index to insert at.
Rest
Value(s) to insert.
Generated using TypeDoc
Inserts the value(s) at the given position. If the index is equal or higher than the array length, the value(s) will be appended. If the index is less than 0, the value(s) will be prepended.
Note that the input array is being mutated.
Since
12.1.0
See
lodash.pullAt
Returns
The mutated array.
Example