Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

foreach break js

var BreakException = {};

try {
  [1, 2, 3].forEach(function(el) {
    console.log(el);
    if (el === 2) throw BreakException;
  });
} catch (e) {
  if (e !== BreakException) throw e;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #foreach #break #js
ADD COMMENT
Topic
Name
3+2 =