i'm confused i was trying to remove object in object array using jquery here is my code , jsFiddle
var x = new Array() ;
var y = {} ;
y.name = 'myName' ;
y.age = 28 ;
y.phone = 27895556 ;
y.info = [{name:'x' ,age:58} ,{name:'y' , age:15}]
x.push(y) ;
$.each(x , function(index,value) {
$.each(value.info , function(i,v){
if(v.name == 'x'){
this.splice(i,1) ;
}
});
});
i was trying to tell the if condition to remove the object with v.name = 'x' but i get this error Uncaught TypeError: Object # has no method 'splice'
UPDATE i need to have something like : y.info = [{name:'x' ,age:58} ,{name:'y' , age:15}] after splice()
any idea what i'm doing wrong Thanks
x.splice-thisis the array element.y.info, i.e. leaving{name: y, age: 15 }, or do want to remove the entire objectyfrom the arrayx?{name: y, age: 15 }