
array.with() – ES2023: Returns a new array with the element at the given index replaced by the provided value (non-mutating).
๐ Syntax
newArray = array.with(index, value);
๐งช Example
const arr=[1,2,3]; const updated=arr.with(1, 99); // [1,99,3]
Comments
Post a Comment