30.
What is the output of the following code snippet?
const arr = [1, 2, 3, 4, 5];
const slicedArr = arr.slice(1, 3);
console.log(typeof slicedArr);
undefined
object
array
number
Correct: B
The slice() method returns an array, and in this code snippet, we assign the returned array to the variable slicedArr. The typeof operator is used to determine the type of the variable slicedArr. The typeof operator treats arrays as objects in JavaScript, so the output will be object.