Array.isArray method

The Array.isArray method checks if the given object is an array. If so, then true is returned, otherwise - false.

Syntax

javascriptArray.isArray(value to check);

Example

Let's check if our object is an array:

javascriptlet res = Array.isArray([1, 2, 3, 4, 5]);
console.log(res);

The code execution result:

javascripttrue

Example

Let's see if the next object is an array:

javascriptlet res = Array.isArray({'a': 1, 'b': 2, 'c': 3});
console.log(res);

The code execution result:

javascriptfalse

See also

  • the includes method
    that checks for the presence of an element in an array
  • the Array.from method
    that obtains an array from an array-like object