()Array.isArray
()Array.isArray
تفحص القيمة التي تم تمريرها هل هي Array
أم ﻻ.
بنية الجملة
Array.isArray(value)
المعلمات
- value
- القيمة التي سيتم فحصها.
القيمة العائدة
تكون القيمة العائدة true
إذا كانت Array
؛ وتكون false
إذا كانت غير ذلك.
الوصف
إذا كانت القيمة Array
, true
ستكون القيمة العائدة؛ غير ذلك ستكون false
.
لمزيد من التفاصيل، راجع هذا المقال “Determining with absolute accuracy whether or not a JavaScript object is an array” .
أمثلة
//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 });
Polyfill
Running the following code before any other code will create Array.isArray()
if it's not natively available.
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
المواصفات
Specification | Status | Comment |
---|---|---|
ECMAScript 5.1 (ECMA-262) The definition of 'Array.isArray' in that specification. |
Standard | Initial definition. Implemented in JavaScript 1.8.5. |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.isArray' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Array.isArray' in that specification. |
Living Standard |
التكامل مع المتصفحات
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 5 | 4.0 (2.0) | 9 | 10.5 | 5 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 4.0 (2.0) | (Yes) | (Yes) | (Yes) |