I don't know who thought it's add good idea to check the index range. (Checked history, but only one issue questioned it, and closed by owner)
if (actualIndex < 0 || actualIndex >= len) {
throw new RangeError();
}
I agree it's safer, but this never happen in other array methods. (except the size of array is too big)
I haven't try to use it, it just an idea.
const replacedLastElement = array.with(-1, 'value'); // throws if it's empty
const clonedAndAppendValue = array.with(array.length, 'value');
// Always throws, have to use old way, though it should be preferred IMO
const clonedAndAppendValue = [...array, 'value'];
Only if .length
checked.
if (array.length > known_length) {
newArray = array.with(1, 'value')
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too