Revision 651685 of yield

  • リビジョンの URL スラグ: Web/JavaScript/Reference/Operators/yield
  • リビジョンのタイトル: yield
  • リビジョンの ID: 651685
  • 作成日:
  • 作成者: alexcastrounis
  • 現行リビジョン いいえ
  • コメント

このリビジョンの内容

Summary


The yield keyword is used to pause and resume a generator.

Syntax

 yield [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.

Description

The yield keyword causes code execution to pause and return the current value of the expression following the yield keyword. It can be thought of as a generator-iterator version of the return keyword.

Examples

Specifications

Specification Status Comment
ECMAScript 6 (ECMA-262) Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (?) (?) (?) (?) (?)

 

See also

このリビジョンのソースコード

<article id="wikiArticle">
 <h2 id="Summary">Summary</h2>
 <br />
 <p>The <code>yield</code> keyword is used to pause and resume a <a href="/en-US/docs/JavaScript/Guide/Iterators_and_Generators#Generators.3A_a_better_way_to_build_Iterators" title="/en-US/docs/JavaScript/Guide/Iterators_and_Generators">generator</a>.</p>
 <h2 id="Syntax" name="Syntax">Syntax</h2>
 <pre class="syntaxbox language-html" data-prism-prevent-line-number="1">
 yield [[expression]];</pre>
<dl>
<dt>
<code>expression</code>
</dt>
<dd>
The expression to return. If omitted, <code>undefined</code> is returned instead.
</dd>
</dl>
<h2 id="Description">Description</h2>
 <p>The&nbsp;<code>yield&nbsp;</code>keyword causes code execution to pause and return the current value of the expression following the <code>yield</code> keyword. It can be thought of as a generator-iterator version of the <code>return</code> keyword.</p>
<h2 id="Examples" name="Examples">Examples</h2>
<p></p>
 <h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td><a class="external external-icon" href="http://people.mozilla.org/~jorendorff/es6-draft.html" hreflang="en" lang="en">ECMAScript 6 (ECMA-262)</a></td>
   <td><span class="spec-Draft">Draft</span></td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
 <h2 id="_Browser_compatibility">Browser compatibility</h2>
 <div class="htab"> 
    <a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a> 
    <ul> 
        <li class="selected"><a>Desktop</a></li> 
        <li class=""><a>Mobile</a></li> 
    </ul> 
<div id="compat-desktop" style="display: block;">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
   </tr>
  </tbody>
 </table>
</div><div id="compat-mobile" style="display: none;">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Chrome for Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
    <td><span style="color: #888;" title="Please update this with the earliest version of support.">(?)</span></td>
   </tr>
  </tbody>
 </table>
</div></div>
 <p>&nbsp;</p>
 <h2 id="See_also" name="See_also">See also</h2>
 <ul>
  <li><a href="/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol">Iterators</a></li>
  <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">Generators</a></li>
<li><a href="/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7">New in JavaScript 1.7</a></li>
 </ul>
</article>
このリビジョンへ戻す