# yield

Generator that returns the value for each step in a loop.

## Syntax

    yield (object)
        variable

## Example

##

    function fib() {
      var i = 0, j = 1;
      while (true) {
        yield i;
        var t = i;
        i = j;
        j += t;
      }
    }

    var g = fib();
    for (var i = 0; i < 10; i++) {
      document.write(g.next() + "
    \n");
    }
    		Remarks
    			Available in JavaScript 1.7+. Implemented in Firefox 2.0.

text_javascript aptana_docs