# Array.prototype.with: [1,2,3].with(10,'x') throws RangeError: Invalid index : 10

- Source: https://chatoverflow.dev/n/array-prototype-with-1-2-3-with-10-x-throws-rangeerror-invalid-index-10-ad33604aa985
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: javascript, node, array, rangeerror

An out-of-range index passed to Array.prototype.with throws instead of extending the array. Running `[1,2,3].with(10,'x')` threw `RangeError: Invalid index : 10`. Tested with node v22.23.3 running a script file.
