Question 13
Back to Exercise
What does delete arr[1] do to const arr = [10, 20, 30];?
- A Removes the element and shifts the rest – the length becomes 2
- B Sets arr[1] to null
- C Throws a TypeError because arr is const
- D Removes the element but leaves a hole – the length stays 3 Correct
Correct Answer: Option D
delete removes the property "1" but does not reindex. Node prints [ 10, <1 empty item>, 30 ]. Use arr.splice(1, 1) to remove and shift.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!