1var myArray = ["one", "two", "three"];
2var cloneArray = myArray.slice();
3
4myArray.splice(1, 1);
5
6console.log(myArray);
7console.log(cloneArray);
1function replaceAt(array, index, value) {
2 const ret = array.slice(0);
3 ret[index] = value;
4 return ret;
5}
6const newArray = replaceAt(items, index, "J");
7
8