Remove A Property From A JavaScript Object

For More Videos Visit Our YouTube Channel




Here we consider how to remove a property from a javascript object. Lets start with one example. Suppose we have a javascript object as shown here.

var object = { "color1": "red", "color2": "blue", "color3": "yellow" };


Now we are going to delete color2 property from this object. The best way is explained here.

delete object.color2;
alert( object.color2 ); --- undefined means it is deleted



delete object.color2 will delete the property color2 from this object. Instead of color2, you can replace as per your requirement. That's all, by this way we can remove a property from a javascript object..