Replace element at specific position in an array without mutating it
<p>How can the following operation be done without mutating the array:</p>

<pre><code>let array = ['item1'];
console.log(array); // ['item1']
array[2] = 'item2'; // array is mutated
console.log(array); // ['item1', undefined, 'item2']
</code></pre>

<p>In the above code, <code>array</code> variable is mutated. How can I perform the same operation without mutating the array?</p>