Skip to main content

@yields

Syntax

@yields {type} description

Overview

@yields documents the value produced by each yield expression in a generator function. It mirrors @returns in structure and usage.

Example

/**
* Generates an infinite sequence of Fibonacci numbers.
* @yields {number} The next Fibonacci number in the sequence.
*/
function* fibonacci() {
let a = 0, b = 1;
while (true) {
yield a;
[a, b] = [b, a + b];
}
}

See also

Official reference: jsdoc.app/tags-yields