foreEach 跳出循环
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