"Fossies" - the Fresh Open Source Software Archive

Member "angular-1.7.9/docs/partials/api/ng/function/angular.forEach.html" (26 Nov 2019, 3631 Bytes) of package /linux/www/angular-1.7.9.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <a href='https://github.com/angular/angular.js/edit/v1.7.x/src/Angular.js?message=docs(angular.forEach)%3A%20describe%20your%20change...#L200' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>
    2 
    3 
    4 
    5 <a href='https://github.com/angular/angular.js/tree/v1.7.9/src/Angular.js#L200' class='view-source pull-right btn btn-primary'>
    6   <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
    7 </a>
    8 
    9 
   10 <header class="api-profile-header">
   11   <h1 class="api-profile-header-heading">angular.forEach</h1>
   12   <ol class="api-profile-header-structure naked-list step-list">
   13     
   14     <li>
   15       - function in module <a href="api/ng">ng</a>
   16     </li>
   17   </ol>
   18 </header>
   19 
   20 
   21 
   22 
   23 
   24 <div class="api-profile-description">
   25   <h2 id="overview">Overview</h2>
   26   <p>Invokes the <code>iterator</code> function once for each item in <code>obj</code> collection, which can be either an
   27 object or an array. The <code>iterator</code> function is invoked with <code>iterator(value, key, obj)</code>, where <code>value</code>
   28 is the value of an object property or an array element, <code>key</code> is the object property key or
   29 array element index and obj is the <code>obj</code> itself. Specifying a <code>context</code> for the function is optional.</p>
   30 <p>It is worth noting that <code>.forEach</code> does not iterate over inherited properties because it filters
   31 using the <code>hasOwnProperty</code> method.</p>
   32 <p>Unlike ES262&#39;s
   33 <a href="http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18">Array.prototype.forEach</a>,
   34 providing &#39;undefined&#39; or &#39;null&#39; values for <code>obj</code> will not throw a TypeError, but rather just
   35 return the value provided.</p>
   36 <pre><code class="lang-js">var values = {name: &#39;misko&#39;, gender: &#39;male&#39;};
   37 var log = [];
   38 angular.forEach(values, function(value, key) {
   39   this.push(key + &#39;: &#39; + value);
   40 }, log);
   41 expect(log).toEqual([&#39;name: misko&#39;, &#39;gender: male&#39;]);
   42 </code></pre>
   43 
   44 </div>
   45 
   46 
   47 
   48 
   49 <div>
   50   
   51 
   52   
   53 
   54   <h2 id="usage">Usage</h2>
   55     
   56       <p><code>angular.forEach(obj, iterator, [context]);</code></p>
   57 
   58 
   59     
   60 
   61     
   62 <section class="api-section">
   63   <h3 id="angular.forEach-arguments">Arguments</h3>
   64 
   65 <table class="variables-matrix input-arguments">
   66   <thead>
   67     <tr>
   68       <th>Param</th>
   69       <th>Type</th>
   70       <th>Details</th>
   71     </tr>
   72   </thead>
   73   <tbody>
   74     
   75     <tr>
   76       <td>
   77         obj
   78         
   79         
   80       </td>
   81       <td>
   82         <a href="" class="label type-hint type-hint-object">Object</a><a href="" class="label type-hint type-hint-array">Array</a>
   83       </td>
   84       <td>
   85         <p>Object to iterate over.</p>
   86 
   87         
   88       </td>
   89     </tr>
   90     
   91     <tr>
   92       <td>
   93         iterator
   94         
   95         
   96       </td>
   97       <td>
   98         <a href="" class="label type-hint type-hint-function">Function</a>
   99       </td>
  100       <td>
  101         <p>Iterator function.</p>
  102 
  103         
  104       </td>
  105     </tr>
  106     
  107     <tr>
  108       <td>
  109         context
  110         
  111         <div><em>(optional)</em></div>
  112       </td>
  113       <td>
  114         <a href="" class="label type-hint type-hint-object">Object</a>
  115       </td>
  116       <td>
  117         <p>Object to become context (<code>this</code>) for the iterator function.</p>
  118 
  119         
  120       </td>
  121     </tr>
  122     
  123   </tbody>
  124 </table>
  125 
  126 </section>
  127     
  128 
  129     <h3 id="angular.forEach-returns">Returns</h3>
  130 <table class="variables-matrix return-arguments">
  131   <tr>
  132     <td><a href="" class="label type-hint type-hint-object">Object</a><a href="" class="label type-hint type-hint-array">Array</a></td>
  133     <td><p>Reference to <code>obj</code>.</p>
  134 </td>
  135   </tr>
  136 </table>
  137 
  138   
  139   
  140   
  141 
  142 
  143 
  144   
  145 </div>
  146 
  147