From 39f2114f9797eb51994966c6bb8ff1814c9a4da8 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:36:08 +0100 Subject: unslug fr: move --- .../functions/arguments/length/index.html | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 files/fr/web/javascript/reference/functions/arguments/length/index.html (limited to 'files/fr/web/javascript/reference/functions/arguments/length/index.html') diff --git a/files/fr/web/javascript/reference/functions/arguments/length/index.html b/files/fr/web/javascript/reference/functions/arguments/length/index.html new file mode 100644 index 0000000000..02de2d281c --- /dev/null +++ b/files/fr/web/javascript/reference/functions/arguments/length/index.html @@ -0,0 +1,91 @@ +--- +title: length +slug: Web/JavaScript/Reference/Fonctions/arguments/length +tags: + - Functions + - JavaScript + - Propriété + - Reference + - arguments +translation_of: Web/JavaScript/Reference/Functions/arguments/length +--- +
{{jsSideBar("Functions")}}
+ +

La propriété arguments.length contient le nombre d'arguments passés à la fonction.

+ +

Syntaxe

+ +
arguments.length
+ +

Description

+ +

La propriété arguments.length fournit le nombre d'arguments qui ont été passés à la fonction. Cette quantité peut être inférieure ou supérieure au nombre de paramètres explicitement déclarés dans la définition de la fonction (voir également {{jsxref("Function.length")}}).

+ +

Exemple

+ +

Utiliser arguments.length

+ +

Dans cet exemple, on définit une fonction qui permet d'additionner plusieurs nombres.

+ +
function somme(x /*, y, z, ...*/) {
+   x = Number(x);
+   for (var i = 1; i < arguments.length; i++) {
+      x += Number(arguments[i]);
+   }
+   return x;
+}
+
+ +
résultat = somme(3, 4, 5);        // renvoie 12
+résultat = somme(3, 4);           // renvoie 7
+résultat = somme(103, 104, 105);  // renvoie 312
+
+ +
+

Note : arguments.length ne doit pas être confondu avec {{jsxref("Function.length")}}.

+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée par JavaScript 1.1
{{SpecName('ES5.1', '#sec-10.6', 'Arguments Object')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ + + +

{{Compat("javascript.functions.arguments.length")}}

+ +

Voir aussi

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