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!