Check Array with Array.isArray()
Write a JavaScript function that takes a value and returns true if it is an array using Array.isArray(), or false otherwise. Array.isArray() is the reliable way to check array types in JavaScript.
Array.isArray() is a static method that determines whether the passed value is an Array. Unlike typeof which returns "object" for arrays, Array.isArray() correctly distinguishes arrays from other objects. This is important because arrays are objects in JavaScript, and the typeof operator cannot differentiate between [] and {}.
Before Array.isArray() was introduced in ES5, developers used workarounds like Object.prototype.toString.call(value) === '[object Array]'. Array.isArray() is now the standard, reliable way to check for arrays. It works across different JavaScript contexts like iframes and windows where instanceof Array may fail due to differing Array constructors.
Time complexity is O(1) as Array.isArray() is a simple internal type check. Space complexity is O(1). The method does not modify the input value or perform any coercion — it returns true only for actual Array instances.
Edge cases include arrays (returns true), objects (returns false), null (returns false), undefined (returns false), strings (returns false), numbers (returns false), and typed arrays like Int8Array (returns false).
Example Input & Output
Null returns false
String returns false
Array of numbers returns true
Object literal returns false
Single-element array returns true
Algorithm Flow

Solution Approach
Best Answers
function solution(val) {
return Array.isArray(val);
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
