LearnFrenzy
Sign in Take a free test

Data Types · JavaScript Data Types MCQ · Question 8

Detecting an array Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What is the most reliable way to check whether a value is an array?

  • A Array.isArray(value) Correct
  • B typeof value === "array"
  • C value instanceof Object
  • D value.length > 0
Correct Answer: Option A

typeof never returns "array", instanceof Object is true for every object, and strings also have length. Array.isArray also works across iframes, where instanceof Array can fail.

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