Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.
Summary
Das length Objekt spezifiziert die Anzahl von Argumenten, welche von der Funktion erwartet werden.
Property attributes of Function.length |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | yes |
Description
length ist ein Objekt einer Funktion, is a property of a function object, and zeigt an wie viele Argumente die Funktion erwartet. Die Anzahl beinhaltet nicht die rest parameter. arguments.length ist hingegen eine lokale Variable innerhalb der Funktion und gibt an, wie viele Argumente tatsächlich übergeben wurden.
Data property of the Function constructor
Der Function constructor ist selbst ein Function Objekt. Sein length data Objekt hat den Wert 1. Das Objekt attributes ist: Writable: false, Enumerable: false, Configurable: true.
Property of the Function prototype object
Das length Objekt des Function prototype Objekts hat den Wert 0.
Examples
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 */
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 1st Edition. | Standard | Initial definition. Implemented in JavaScript 1.1. |
length property of the Function constructor:ECMAScript 5.1 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. length property of the Function prototype object:ECMAScript 5.1 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. length property of Function instances:ECMAScript 5.1 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. |
Standard | |
length property of the Function constructor:ECMAScript 6 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. length property of the Function prototype object:ECMAScript 6 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. length property of Function instances:ECMAScript 6 (ECMA-262) Die Definition von 'Function.length' in dieser Spezifikation. |
Anwärter Empfehlung | The configurable attribute of this property is now true. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) |
| Configurable: true | ? | 37 (37) | ? | ? | ? |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) |
| Configurable: true | ? | ? | 37.0 (37) | ? | ? | ? |