From a55b575e8089ee6cab7c5c262a7e6db55d0e34d6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:46:50 +0100 Subject: unslug es: move --- .../global_objects/function/length/index.html | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 files/es/web/javascript/reference/global_objects/function/length/index.html (limited to 'files/es/web/javascript/reference/global_objects/function/length') diff --git a/files/es/web/javascript/reference/global_objects/function/length/index.html b/files/es/web/javascript/reference/global_objects/function/length/index.html new file mode 100644 index 0000000000..7638859bba --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/function/length/index.html @@ -0,0 +1,151 @@ +--- +title: Function.length +slug: Web/JavaScript/Referencia/Objetos_globales/Function/length +tags: + - JavaScript + - Propiedad + - función +translation_of: Web/JavaScript/Reference/Global_Objects/Function/length +--- +
{{JSRef("Global_Objects", "Function")}}
+ +

Sumario

+ +

La propiedad length especifica el número de argumentos esperados por la función.

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

Descripción

+ +

length es la propiedad de una función objeto, e indica el número de argumentos que una función requiere, por ejemplo, el número de parámetros formales. Este número no incluye {{jsxref("rest_parameters", "rest parameter", "", 1)}}. En cambio, {{jsxref("Functions_and_function_scope/arguments/length", "arguments.length")}} es local a una función y aporta el número de argumentos actuales pasados a una función.

+ +

Propiedades de la Función constructora

+ +

El {{jsxref("Global_Objects/Function", "Function")}} constructor en sí mismo es {{jsxref("Global_Objects/Function", "Function")}} un objeto. Sú propiedad length tiene el valor 1. Los atributos son: Grabable: false, Enumerable: false, Configurable: true.

+ +

Propiedad de la  Función prototype object

+ +

La propiedad length del {{jsxref("Global_Objects/Function", "Function")}} objeto prototype tiene el valor 0.

+ +

Ejemplos

+ +
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, resto de parámetros no se contemplan */
+console.log((function(a, b = 1, c) {}).length); /* 1, solo parámetros antes del primero con un valor por defecto son contados */
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
ECMAScript 1st Edition.StandardDefinición inicial. Implementado en JavaScript 1.1.
length property of the {{jsxref("Global_Objects/Function", "Function")}} constructor:
+ {{SpecName('ES5.1', '#sec-15.3.3.2', 'Function.length')}}
+ length property of the {{jsxref("Global_Objects/Function", "Function")}} prototype object:
+ {{SpecName('ES5.1', '#sec-properties-of-the-function-prototype-object', 'Function.length')}}
+ length property of {{jsxref("Global_Objects/Function", "Function")}} instances:
+ {{SpecName('ES5.1', '#sec-15.3.5.1', 'Function.length')}}
{{Spec2('ES5.1')}}
length property of the {{jsxref("Global_Objects/Function", "Function")}} constructor:
+ {{SpecName('ES6', '#sec-function.length', 'Function.length')}}
+ length property of the {{jsxref("Global_Objects/Function", "Function")}} prototype object:
+ {{SpecName('ES6', '#sec-15.3.4', 'Function.length')}}
+ length property of {{jsxref("Global_Objects/Function", "Function")}} instances:
+ {{SpecName('ES6', '#sec-function-instances-length', 'Function.length')}}
{{Spec2('ES6')}}El atributo configurable de esta propiedad ahora es true.
+ +

Compatibilidad con navegadores

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatGeckoDesktop(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Soporte básico{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Ver también

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