24.
What will be the value of arr after executing the following code?
const arr = [1, 2, 3, 4, 5];
const slicedArr = arr.slice(1, 3);
console.log(arr)
[1, 3, 4, 5]
[2, 3]
[2, 3, 4]
[1, 2, 3, 4, 5]
Correct: D
The slice() method does not modify the original array but instead returns a new array with the selected elements. In this code, arr remains unchanged, it will have the original value of [1, 2, 3, 4, 5] even after executing the slice() method.