A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Generator/next below:

Generator.prototype.next() - JavaScript | MDN

Generator.prototype.next()

Baseline Widely available

El método next() regresa un objeto con las propiedades done y value. También puedes pasar un parámetro al método next para enviar un valor al generador.

Sintaxis Parámetros
valor

El valor a enviar al generador.

Valor de retorno

Un Object con dos propiedades:

Examples Using next()

The following example shows a simple generator and the object that the next method returns:

function* gen() {
  yield 1;
  yield 2;
  yield 3;
}

var g = gen(); // "Generator { }"
g.next(); // "Object { value: 1, done: false }"
g.next(); // "Object { value: 2, done: false }"
g.next(); // "Object { value: 3, done: false }"
g.next(); // "Object { value: undefined, done: true }"
Sending values to the generator

In this example, next is called with a value. Note that the first call did not log anything, because the generator was not yielding anything initially.

function* gen() {
  while (true) {
    var value = yield null;
    console.log(value);
  }
}

var g = gen();
g.next(1);
// "{ value: null, done: false }"
g.next(2);
// 2
// "{ value: null, done: false }"
Especificaciones Compatibilidad con navegadores See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4