Repository navigation
Expand file tree
/
Copy pathindex.md
More file actions
84 lines (58 loc) · 3.69 KB
/
Copy pathindex.md
File metadata and controls
84 lines (58 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: AsyncGeneratorFunction
slug: Web/JavaScript/Reference/Global_Objects/AsyncGeneratorFunction
l10n:
sourceCommit: 544b843570cb08d1474cfc5ec03ffb9f4edc0166
---
Das **`AsyncGeneratorFunction`**-Objekt stellt Methoden für [asynchrone Generatorfunktionen](/de/docs/Web/JavaScript/Reference/Statements/async_function*) bereit. In JavaScript ist jede asynchrone Generatorfunktion tatsächlich ein `AsyncGeneratorFunction`-Objekt.
Beachten Sie, dass `AsyncGeneratorFunction` _kein_ globales Objekt ist. Es kann mit dem folgenden Code erhalten werden:
```js
const AsyncGeneratorFunction = async function* () {}.constructor;
```
`AsyncGeneratorFunction` ist eine Unterklasse von {{jsxref("Function")}}.
{{InteractiveExample("JavaScript Demo: AsyncGeneratorFunction", "taller")}}
```js interactive-example
const AsyncGeneratorFunction = async function* () {}.constructor;
const foo = new AsyncGeneratorFunction(`
yield await Promise.resolve('a');
yield await Promise.resolve('b');
yield await Promise.resolve('c');
`);
let str = "";
async function generate() {
for await (const val of foo()) {
str += val;
}
console.log(str);
}
generate();
// Expected output: "abc"
```
## Konstruktor
- {{jsxref("AsyncGeneratorFunction/AsyncGeneratorFunction", "AsyncGeneratorFunction()")}}
- : Erstellt ein neues `AsyncGeneratorFunction`-Objekt.
## Instanz-Eigenschaften
_Erbt auch Instanz-Eigenschaften von seinem Elternobjekt {{jsxref("Function")}}._
Diese Eigenschaften sind auf `AsyncGeneratorFunction.prototype` definiert und werden von allen `AsyncGeneratorFunction`-Instanzen geteilt.
- {{jsxref("Object/constructor", "AsyncGeneratorFunction.prototype.constructor")}}
- : Die Konstruktorfunktion, die das Instanzobjekt erstellt hat. Für `AsyncGeneratorFunction`-Instanzen ist der Anfangswert der {{jsxref("AsyncGeneratorFunction/AsyncGeneratorFunction", "AsyncGeneratorFunction")}}-Konstruktor.
- `AsyncGeneratorFunction.prototype.prototype`
- : Alle asynchronen Generatorfunktionen teilen die gleiche [`prototype`](/de/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype)-Eigenschaft, die [`AsyncGenerator.prototype`](/de/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator) ist. Jede asynchrone Generatorfunktion, die mit der `async function*`-Syntax oder dem `AsyncGeneratorFunction()`-Konstruktor erstellt wird, hat auch ihre eigene `prototype`-Eigenschaft, deren Prototyp `AsyncGeneratorFunction.prototype.prototype` ist. Wenn die asynchrone Generatorfunktion aufgerufen wird, wird ihre `prototype`-Eigenschaft zum Prototyp des zurückgegebenen asynchronen Generatorobjekts.
- `AsyncGeneratorFunction.prototype[Symbol.toStringTag]`
- : Der Anfangswert der [`[Symbol.toStringTag]`](/de/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag)-Eigenschaft ist der String `"AsyncGeneratorFunction"`. Diese Eigenschaft wird in {{jsxref("Object.prototype.toString()")}} verwendet.
Diese Eigenschaften sind eigene Eigenschaften jeder `AsyncGeneratorFunction`-Instanz.
- {{jsxref("AsyncGeneratorFunction/prototype", "prototype")}}
- : Wird verwendet, wenn die Funktion als Konstruktor mit dem [`new`](/de/docs/Web/JavaScript/Reference/Operators/new)-Operator verwendet wird. Sie wird zum Prototyp des neuen Objekts.
## Instanz-Methoden
_Erbt Instanz-Methoden von seinem Elternobjekt {{jsxref("Function")}}._
## Spezifikationen
{{Specifications}}
## Browser-Kompatibilität
{{Compat}}
## Siehe auch
- [`async function*`](/de/docs/Web/JavaScript/Reference/Statements/async_function*)
- [`async function*`-Ausdruck](/de/docs/Web/JavaScript/Reference/Operators/async_function*)
- {{jsxref("Function")}}
- {{jsxref("AsyncFunction")}}
- {{jsxref("GeneratorFunction")}}
- {{jsxref("Functions", "Funktionen", "", 1)}}