[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction [Back]  [Original]

GeneratorFunction - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

GeneratorFunction

Baseline
Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2016 ..

GeneratorFunction -. JavaScript - GeneratorFunction.

, GeneratorFunction . :

js
const GeneratorFunction = function* () {}.constructor;

GeneratorFunction Function.

In this article

const GeneratorFunction = function* () {}.constructor;

const foo = new GeneratorFunction(`
  yield 'a';
  yield 'b';
  yield 'c';
`);

let str = "";
for (const val of foo()) {
  str = str + val;
}

console.log(str);
// Expected output: "abc"

GeneratorFunction()

GeneratorFunction.

Function.

GeneratorFunction.prototype GeneratorFunction.

GeneratorFunction.prototype.constructor

-, . GeneratorFunction GeneratorFunction.

GeneratorFunction.prototype.prototype

- prototype, Generator.prototype. - prototype. - , prototype -, GeneratorFunction.prototype.prototype.

GeneratorFunction.prototype[@@toStringTag]

@@toStringTag "GeneratorFunction". Object.prototype.toString().

Function.

Specification
ECMAScript 2027 LanguageSpecification
# sec-generatorfunction-objects


Web Proxy Viewer  |  New URL  |  Original Page