A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Functions/arguments/length below:

length - JavaScript | MDN

length

Baseline Widely available

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

Syntaxe 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 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 Function.length.

Spécifications Compatibilité des navigateurs Voir aussi

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4