[SERVER-4826] Break forEach loop Created: 31/Jan/12 Updated: 29/Feb/12 Resolved: 31/Jan/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Kirk Morales | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
Ability to stop iterating on a forEach by returning false, similar to jQuery: http://api.jquery.com/jQuery.each/ The following code would print only 1 & 2. [1,2,3,4].forEach(function(v) { print(v); if (v >= 3) {return false; }}) |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 31/Jan/12 ] |
|
[1,2,3,4] is a standard javascript array. jQuery.each is a helper - which can be loaded into shell if you want |