Saturday 27 May 2023

Short circuit Array.forEach like calling break

[1,2,3].forEach(function(el) {
    if(el === 1) break;
});

How can I do this using the new forEach method in JavaScript? I've tried return;, return false; and break. break crashes and return does nothing but continue iteration.



from Short circuit Array.forEach like calling break

No comments:

Post a Comment