georgiev955

Untitled

Sep 15th, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. let arr = [1, 2, 3, 4, 5];
  2.  
  3. //спира forEach
  4. arr.forEach((num) => {
  5. if (num === 2) {
  6. throw new Error('Num is 2');
  7. } else {
  8. console.log(num)
  9. }
  10. });
  11.  
  12. //не го спира
  13. arr.forEach((num) => {
  14. if (num === 2) {
  15. return;
  16. } else {
  17. console.log(num)
  18. }
  19. });
  20.  
Advertisement
Add Comment
Please, Sign In to add comment