From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../global_objects/function/length/index.html | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 files/pt-br/web/javascript/reference/global_objects/function/length/index.html (limited to 'files/pt-br/web/javascript/reference/global_objects/function/length') diff --git a/files/pt-br/web/javascript/reference/global_objects/function/length/index.html b/files/pt-br/web/javascript/reference/global_objects/function/length/index.html new file mode 100644 index 0000000000..a116f07892 --- /dev/null +++ b/files/pt-br/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}}
+ +

A propriedade length especifica o número de argumentos esperados pela função.

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

Descrição

+ +

length é uma propriedade de um objeto função, e indica quantos argumentos a função espera, i.e. o número de parametros formais. Este número não incluí o {{jsxref("rest_parameters", "rest parameter", "", 1)}}. Por contraste, {{jsxref("Functions_and_function_scope/arguments/length", "arguments.length")}} é local para a função e fornece o número de argumentos que foram realmente passados.

+ +

Propriedade de Dados do construtor Function

+ +

O construtor {{jsxref("Function")}} é propriamente um objeto {{jsxref("Function")}}. A proproedade de dados do seu length tem o valor de 1. Os atributos da propriedade são: Escrita: false, Enumerável: false, Configurável: true.

+ +

Propriedades do objeto prototype de Function

+ +

A propriedade length do objeto prototype {{jsxref("Function")}} tem o valor de 0.

+ +

Exemplos

+ +
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, rest parameter is not counted */
+
+ +

Especificações

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in 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')}}The configurable attribute of this property is now true.
+ +

Compatibilidade com o Navegador

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatGeckoDesktop(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Configurable: true{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Veja tambem

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