From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../global_objects/function/length/index.html | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/function/length/index.html (limited to 'files/ca/web/javascript/reference/global_objects/function/length/index.html') diff --git a/files/ca/web/javascript/reference/global_objects/function/length/index.html b/files/ca/web/javascript/reference/global_objects/function/length/index.html new file mode 100644 index 0000000000..2af00ebf41 --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/function/length/index.html @@ -0,0 +1,134 @@ +--- +title: Function.length +slug: Web/JavaScript/Reference/Global_Objects/Function/length +translation_of: Web/JavaScript/Reference/Global_Objects/Function/length +--- +
{{JSRef}}
+ +

La propietat length especifica el nombre d'arguments que la funció espera.

+ +
{{js_property_attributes(0,0,1)}}
+ +

Descripció

+ +

length és una propietat d'un objecte funció, i indica quants arguments la funció espera,  és a dir, el nombre de paràmetres formals. Aquest nombre no inclou el  {{jsxref("rest_parameters", "rest parameter", "", 1)}}. Per contra, {{jsxref("Functions_and_function_scope/arguments/length", "arguments.length")}} és local a la funció i retorna el nombre d'arguments que s'han passat a la funció.

+ +

Propietat Data del constructor Function

+ +

El constructor {{jsxref("Function")}} és per ell mateix un objecte {{jsxref("Function")}}. La seva propietat data length pren un valor d'1. Els atributs de la propietat són: Writable: false, Enumerable: false, Configurable: true.

+ +

Propietat de l'objecte prototipus Function

+ +

La propietat length de l'objecte prototipus {{jsxref("Function")}} pren un valor de 0.

+ +

Exemples

+ +
console.log(Function.length); /* 1 */
+
+console.log((function()        {}).length); /* 0 */
+console.log((function(a)       {}).length); /* 1 */
+console.log((function(a, b)    {}).length); /* 2 etc. */
+console.log((function(...args) {}).length); /* 0, la resta de paràmetres no es conta */
+
+ +

Especificacions

+ + + + + + + + + + + + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES1')}}{{Spec2('ES1')}}Definció inicial. Implementat en JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.3.5.1', 'Function.length')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-function-instances-length', 'Function.length')}}{{Spec2('ES6')}}L'atribut configurable d'aquesta propietat és ara  true.
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatGeckoDesktop(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome per AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Vegeu també

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