Denis Ermolin's answer is an option, though a few problems might occur, here's what I suggest:
for(var i=0;i<y.length;i++)
{
if (y[i].hasOwnProperty('id') && y[i].id === 23)
{
delete(y[i]);
break;
}
}
When using arrays, it's always better to avoid the for - in
loop, as this will loop through the Array.prototype
, so i
might suddenly contain length
, not an index number.
When you're dealing with objects, the for in
loop is a great thing, but again: it loops through the prototypes, that's why you're better off using the hasOwnProperty
method.
The rest is pretty strait forward, I think... good luck