Check if an object is an array:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
let result = Array.isArray(fruits);
Check if another datatype is an array:
let text = "W3Schools";
let result = Array.isArray(text);
The isArray()
method returns true
if an object is an array, otherwise false
.
Array.isArray() is a static property of the JavaScript Array object.
You can only use it as Array.isArray().
Using x.isArray(), where x is an array will return undefined.
Syntax Parameters Parameter Description obj Required.true
if the object is an array, otherwise false
. Browser Support
isArray()
is an ECMAScript5 (ES5 2009) feature.
JavaScript 2009 is supported in all browsers since July 2013:
ChromeTrack your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4