How To Break Out From Foreach Loop In Javascript
I am newbie in Javascrript. I have a variable having following details: var result = false; [{'a': '1','b': null},{'a': '2','b': 5}].forEach(function(call){ console.log(call);
Solution 1:
Use a for
loop instead of .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
}
}
Post a Comment for "How To Break Out From Foreach Loop In Javascript"