How can the following operation be done without mutating the array:
let array = [\'item1\']; console.log(array); // [\'item1\'] array[2] = \'item2\'; // array is
var list1 = ['a','b','c']; var list2 = list1.slice(); list2.splice(2, 0, "beta", "gamma"); console.log(list1); console.log(list2);
Is this what you want?