How can I break out of forEach or re structure my function?

This question already has an answer here:

  • How to short circuit Array.forEach like calling break? 24 answers

  • Use .some() instead of .forEach() , and return true when you want to break.

    Or .every() , and return false to break.


        //...
        //WOULD LIKE TO PUT BREAK HERE;
        // break;
        return;
    

    'return'适合我。

    链接地址: http://www.djcxy.com/p/70062.html

    上一篇: 返回Array.forEach中函数的值而不是内部函数的值

    下一篇: 我如何摆脱forEach或重新构造我的功能?