Array.isArray
Determines whether the passed value is an Array
Syntax
Array.isArray(value)Parameters
| Parameter | Type | Description |
|---|---|---|
| value | any | The value to be checked |
Return Value
true if the value is an Array; otherwise, false
Examples
console.log(Array.isArray([1, 2, 3])); // true
console.log(Array.isArray('hello')); // falseconsole.log(Array.isArray(new Array())); // true
console.log(Array.isArray({ length: 3 })); // falsefunction process(input: unknown) {
if (Array.isArray(input)) {
return input.map(String);
}
return [String(input)];
}Understanding Array.isArray
The Array.isArray method in JavaScript determines whether the passed value is an Array. It belongs to the Array object and is one of the most widely used methods for working with array values in modern JavaScript and TypeScript applications.
The method signature is Array.isArray(value). It accepts 1 parameter: value. When called, it returns true if the value is an array; otherwise, false. Understanding when and how to use isArray() helps you write more expressive, readable code.
Common use cases for Array.isArray include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like array-from, array-of, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Array.isArray is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Array Methods
Other methods in the Array object
Related Tools
More Array Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.