Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let arr = [1, 2, 3, 4, 5];
- //спира forEach
- arr.forEach((num) => {
- if (num === 2) {
- throw new Error('Num is 2');
- } else {
- console.log(num)
- }
- });
- //не го спира
- arr.forEach((num) => {
- if (num === 2) {
- return;
- } else {
- console.log(num)
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment