js pop array without mutating code example
Example 1: how to push into array javascript without mutating
const newArray = array.contact(newItem);
Example 2: how to replace array element in javascript without mutation
function replaceAt(array, index, value) {
const ret = array.slice(0);
ret[index] = value;
return ret;
}
const newArray = replaceAt(items, index, "J");