ember / 3.25.0 / functions / @ember / array / isarray.html /

Function

isArray (obj) Boolean public

Module: ember
import { isArray } from '@ember/array';
obj
Object
The object to test
returns
Boolean
true if the passed object is an array or Array-like

Returns true if the passed object is an array or Array-like.

Objects are considered Array-like if any of the following are true:

  • the object is a native Array
  • the object has an objectAt property
  • the object is an Object, and has a length property

Unlike typeOf this method returns true even if the passed object is not formally an array but appears to be array-like (i.e. implements Array)

import { isArray } from '@ember/array';
import ArrayProxy from '@ember/array/proxy';

isArray();                                      // false
isArray([]);                                    // true
isArray(ArrayProxy.create({ content: [] }));    // true

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/3.25/functions/@ember%2Farray/isArray