Remove a Property from an Object

Remove a Property from an Object in JavaScript

 

In this example, you will learn to write a JavaScript program that will remove a property from an object.

To understand this example, you should have the knowledge of the following JavaScript programming topics:


JavaScript Objects

An object is written in a key/value pair. The key/value pair is called a property. For example,

Here, name: 'John' and age: 22 are the two properties of a student object.


Example: Remove a Property From an Object

In the above program, the delete operator is used to remove a property from an object.

You can use the delete operator with . or [ ] to remove the property from an object.

Note: You should not use the delete operator on predefined JavaScript object properties. 

Post a Comment

Previous Post Next Post