LearnFrenzy
Sign in Take a free test

Operators · JavaScript Operators MCQ · Question 13

delete on an array element Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links