const data=[{"NAME":"ABC","ID":"1","CATALOG":"PDC"},{"NAME":"DOT","ID":"88","CATALOG":"PDC"},{"NAME":"TIM","ID":"99","CATALOG":"PDC"},{"NAME":"TOM","ID":"19","CATALOG":"PDC"},{"NAME":"CAT","ID":"18"},{"NAME":"BAT","ID":"13"},{"NAME":"XYZ","ID":"12"},{"NAME":"PQR","ID":"11"}]
for(var i=0;i<data.length;i++)
{
if (data[i].hasOwnProperty('CATALOG'))
{
console.log(data[i].ID)
}
else
{
data.splice(i,1)
//delete(data[i])
}
}
console.log(data)
Above is my code but the result is not what is expected. The last 2 rows are being retained when using splice and using delete() creates undefined in place of the object without the property CATALOG.