118 of 264 menu

Array.isArray method

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

Syntax

Array.isArray(value to check);

Example

Let's check if our object is an array:

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

The code execution result:

true

Example

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

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

The code execution result:

false

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
byenru