How to break out from foreach loop in javascript

This question already has an answer here:

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

  • 不要使用.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/70044.html

    上一篇: Coffeescript:分解forEach循环

    下一篇: 如何从JavaScript中的foreach循环中跳出来