Negative indices count backwards from the end of the array. If index is fractional or otherwise invalid, returns a shallow copy of the array.
index
import * as A from "flurp/array";const firstToTen = A.set(0, 10);firstToTen([3, 4, 5, 6]); // [10, 4, 5, 6]const lastToTen = A.set(-1, 10);lastToTen([3, 4, 5, 6]); // [3, 4, 5, 10]
the index at which to update
the new value of the element
Negative indices count backwards from the end of the array. If
index
is fractional or otherwise invalid, returns a shallow copy of the array.Example