LearnFrenzy
Sign in Take a free test

Arrays · JavaScript Arrays MCQ · Question 7

typeof an array Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

What does typeof [1, 2, 3] return, and how should you test for an array?

  • A "array" – typeof is enough
  • B "list" – use instanceof List
  • C "object" – use value.length > 0
  • D "object" – use Array.isArray(value) Correct
Correct Answer: Option D

Arrays are objects, so typeof cannot tell them apart. Array.isArray is reliable, even across iframes.

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