如何从JavaScript中的foreach循环中跳出来

这个问题在这里已经有了答案:

  • 如何使Array.forEach短路像调用break? 24个答案

  • 不要使用.forEach然后循环:

    var myObj = [{"a": "1","b": null},{"a": "2","b": 5}]
    var result = false
    
    for(var call of myObj) {
        console.log(call)
    
        var a = call['a'], b = call['b']
    
        if(a == null || b == null) {
            result = false
            break
        }
    }
    
    链接地址: http://www.djcxy.com/p/70043.html

    上一篇: How to break out from foreach loop in javascript

    下一篇: What does `return` keyword mean inside `forEach` function?