I want to delete json elements which are satisfying the condition. For that I used the given code
var index = -1;
for (var i = 0; i < data.dashLayout.dashlets.length; i++) {
if (data.dashLayout.dashlets[i].rowNo == selectedrowno) {
if (index == -1 || data.dashLayout.dashlets[i].rowNo < data.dashLayout.dashlets[index].rowNo) {
index = i;
}
}
if (index != -1) {
data.dashLayout.dashlets.splice(index, 1);
}
}
But iteration is not completing because the data.dashLayout.dashlets.length is reducing with splice. How can I solve this issue? I want to delete all items that are satisfying the condition. Please help
iinside theifthat does the.splice(). (Also, there's no JSON in your code: JSON is a string format. What you have is objects and an array.)