Remove Object from Array using JavaScript

JSON object is very important type in JavaScript, now days it’s very easy to handle json object with help of jQuery, here we will discuss how to remove an object from JavaScript array. It’s very easy and simple.I am using Delete() method to remove object from array.

Remove an Object from Array using javascript

ex: We have following JavaScript array:

I want to do remove Red from colors array.

Using delete method:

we will use Delete method to remove object of specific index.

The resulting array would be:

But main problem is that when you are iterating on this array you will get element is undefined array error, Avoid this array you can add check condition for undefined.

Now you can use below method to skip undefined object from array.

The resule would as below:

Using Splice method:

You can also use splice if you have known about target object index:

The resule would as below: