From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../global_objects/array/isarray/index.html | 114 --------------------- .../global_objects/array/isarray/index.md | 114 +++++++++++++++++++++ 2 files changed, 114 insertions(+), 114 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/array/isarray/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/array/isarray/index.md (limited to 'files/fr/web/javascript/reference/global_objects/array/isarray') diff --git a/files/fr/web/javascript/reference/global_objects/array/isarray/index.html b/files/fr/web/javascript/reference/global_objects/array/isarray/index.html deleted file mode 100644 index f57266afff..0000000000 --- a/files/fr/web/javascript/reference/global_objects/array/isarray/index.html +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: Array.isArray() -slug: Web/JavaScript/Reference/Global_Objects/Array/isArray -tags: - - Array - - ECMAScript 5 - - JavaScript - - Méthode - - Reference - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Array/isArray -original_slug: Web/JavaScript/Reference/Objets_globaux/Array/isArray ---- -
{{JSRef}}
- -

La méthode Array.isArray() permet de déterminer si l'objet passé en argument est un objet {{jsxref("Array")}}, elle renvoie true si le paramètre passé à la fonction est de type Array et false dans le cas contraire.

- -
Array.isArray([1, 2, 3]);   // true
-Array.isArray({toto: 123}); // false
-Array.isArray("tototruc");  // false
-Array.isArray(undefined);   // false
-
- -

Syntaxe

- -
Array.isArray(value)
- -

Paramètres

- -
-
value
-
La valeur dont on veut vérifier le type
-
- -

Valeur de retour

- -

true si la valeur est un tableau (une instance de {{jsxref("Array")}}), false sinon.

- -

Description

- -

Si l'objet indiqué en paramètre est un {{jsxref("Array")}}, la méthode renvoie true, sinon, elle renvoie false.

- -

Voir aussi : « Determining with absolute accuracy whether or not a JavaScript object is an array » (en anglais) pour avoir plus de détails. Si on passe un objet {{jsxref("TypedArray")}} en argument, ce sera toujours la valeur false qui sera renvoyée.

- -

Exemples

- -
// Tous les appels suivant renvoient true
-Array.isArray([]);
-Array.isArray([1]);
-Array.isArray(new Array());
-Array.isArray(new Array('a', 'b', 'c'));
-Array.isArray(new Array(3));
-// Une petite anecdote: Array.prototype lui même est un Array
-Array.isArray( Array.prototype );
-
-// Tous les appels suivant renvoient 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(new Uint8Array(32));
-Array.isArray({ __proto__ : Array.prototype });
-
- -

Prothèse d'émulation (polyfill)

- -

Exécuter ce code avant tout les autres aboutira à la création de la méthode Array.isArray()si elle n'est pas nativement prise en charge par le navigateur.

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

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.4.3.2', 'Array.isArray')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec JavaScript 1.8.5.
{{SpecName('ES6', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.Array.isArray")}}

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/array/isarray/index.md b/files/fr/web/javascript/reference/global_objects/array/isarray/index.md new file mode 100644 index 0000000000..f57266afff --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/array/isarray/index.md @@ -0,0 +1,114 @@ +--- +title: Array.isArray() +slug: Web/JavaScript/Reference/Global_Objects/Array/isArray +tags: + - Array + - ECMAScript 5 + - JavaScript + - Méthode + - Reference + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Array/isArray +original_slug: Web/JavaScript/Reference/Objets_globaux/Array/isArray +--- +
{{JSRef}}
+ +

La méthode Array.isArray() permet de déterminer si l'objet passé en argument est un objet {{jsxref("Array")}}, elle renvoie true si le paramètre passé à la fonction est de type Array et false dans le cas contraire.

+ +
Array.isArray([1, 2, 3]);   // true
+Array.isArray({toto: 123}); // false
+Array.isArray("tototruc");  // false
+Array.isArray(undefined);   // false
+
+ +

Syntaxe

+ +
Array.isArray(value)
+ +

Paramètres

+ +
+
value
+
La valeur dont on veut vérifier le type
+
+ +

Valeur de retour

+ +

true si la valeur est un tableau (une instance de {{jsxref("Array")}}), false sinon.

+ +

Description

+ +

Si l'objet indiqué en paramètre est un {{jsxref("Array")}}, la méthode renvoie true, sinon, elle renvoie false.

+ +

Voir aussi : « Determining with absolute accuracy whether or not a JavaScript object is an array » (en anglais) pour avoir plus de détails. Si on passe un objet {{jsxref("TypedArray")}} en argument, ce sera toujours la valeur false qui sera renvoyée.

+ +

Exemples

+ +
// Tous les appels suivant renvoient true
+Array.isArray([]);
+Array.isArray([1]);
+Array.isArray(new Array());
+Array.isArray(new Array('a', 'b', 'c'));
+Array.isArray(new Array(3));
+// Une petite anecdote: Array.prototype lui même est un Array
+Array.isArray( Array.prototype );
+
+// Tous les appels suivant renvoient 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(new Uint8Array(32));
+Array.isArray({ __proto__ : Array.prototype });
+
+ +

Prothèse d'émulation (polyfill)

+ +

Exécuter ce code avant tout les autres aboutira à la création de la méthode Array.isArray()si elle n'est pas nativement prise en charge par le navigateur.

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

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.4.3.2', 'Array.isArray')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec JavaScript 1.8.5.
{{SpecName('ES6', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

{{Compat("javascript.builtins.Array.isArray")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf