114
rated 0 times
[
116]
[
2]
/ answers: 1 / hits: 16568
/ 7 Years ago, tue, july 11, 2017, 12:00:00
I am having an object like below.i will loop through the array of objects and check for any object property has value.the following code works very fine, it sets a flag to true,if any of the objects has an
empty value,but it doesn't break out of the obj.forEach loop it just exists out of the immediate parent for loop only.how to exit out of the obj.forEach loop if any of the object property has
value
var obj = [
{
fname: name1,
lname:
},
{
fname: name2,
lname: lname2
},
{
fname: ,
lname: lname3
}
];
var hasEmptyValue = false
var hasEmptyProperty = obj3.forEach(function(item) {
for (var key in item) {
if (item.hasOwnProperty(key) && item[key] == ) {
saveIt = true;
break;
}
console.log(key->,key,value ->,item[key]);
}
});
More From » javascript