Removing Matched Object From Array Of Objects Using Javascript
I have an array of 4 objects and each object contains property array of 8 object. I am trying to remove an object from properties Array[8] var responseArray = new Array()
Solution 1:
- Pop method is not suitable to remove specific object from an array
The pop() method removes the last element from an array and returns that element.
- You should remove object from
responseArray.properties
array instead ofresponseArray
Replace responseArray.pop(checkProp);
with resProp.properties.splice( resProp.properties.indexOf(checkProp) , 1 );
Post a Comment for "Removing Matched Object From Array Of Objects Using Javascript"