[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.
We do not want the shell to be a non-standard javascript environment.

jQuery.each is a helper - which can be loaded into shell if you want

Generated at Thu Feb 08 03:07:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.