const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const _ = require('lodash');

let outArr = [];
try {
    arr.forEach(obj => {
        console.log(obj);
        if (obj < 3) {
            outArr.push(obj);
        } else {
            throw new Error('brack');
        }
    });
} catch (err) {
}

方法一: try catch

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-12-12
  • 2021-12-12
  • 2021-11-14
  • 2021-12-12
猜你喜欢
  • 2022-02-27
  • 2021-12-12
  • 2021-08-17
  • 2021-06-13
  • 2022-12-23
相关资源
相似解决方案