[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray [Back]  [Original]

Array.isArray() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Array.isArray()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

Array.isArray() true, false, .

In this article

Array.isArray(obj)

obj

.

true Array; , false.

, JavaScript- .

js
//     true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
//  : Array.prototype   :
Array.isArray(Array.prototype);

//     false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray("Array");
Array.isArray(true);
Array.isArray(false);
Array.isArray({ __proto__: Array.prototype });

instanceof vs isArray

Array, Array.isArray , instanceof, iframes.

js
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
xArray = window.frames[window.frames.length - 1].Array;
var arr = new xArray(1, 2, 3); // [1,2,3]

// Correctly checking for Array
Array.isArray(arr); // true
// Considered harmful, because doesn't work through iframes
arr instanceof Array; // false

Array.isArray(), .

js
if (!Array.isArray) {
  Array.isArray = function (arg) {
    return Object.prototype.toString.call(arg) === "[object Array]";
  };
}

Specification
ECMAScript 2027 LanguageSpecification
# sec-array.isarray


Web Proxy Viewer  |  New URL  |  Original Page