How to Remove a Property From JavaScript Object? Last Updated : 24 Oct, 2024 Comments Improve Suggest changes Like Article Like Report The delete operator is used to remove a property from a JavaScript object. The delete operator allows you to remove a specified property from an object. Once a property is deleted, it no longer exists in the object.Using delete OperatorThe basic method to remove a property from a JavaScript object is by using the delete operator. This operator removes the property from the object and returns true if the operation is successful.Syntaxdelete object.propertyName;Alternatively, you can use the bracket notation if the property name is stored as a variable:delete object["propertyName"];Example: Remove the property from object using delete operator. JavaScript let obj = { name: "Rohit", age: 24, city: "Noida" }; // Using delete to remove the 'age' property delete obj.age; console.log(obj); Output{ name: 'Rohit', city: 'Noida' } Apart from the delete operator you can also use different approaches to remove property from JavaScript Object.Table of ContentUsing Object DestructuringUsing Reflect.deleteProperty Which Approach Is Better in Different Cases?Remove a Property From JavaScript Object - FAQsUsing Object DestructuringObject destructuring can be used to create a new object excluding the property you need to remove. This approach does not mutate the original object but returns a new object without the specified property.Example: Remove the property from object using object destructuring. JavaScript let obj = { name: "Rohit", age: 24, city: "Noida" }; // Using destructuring to remove // 'age' property const { age, ...obj1 } = obj; // obj1 is the updated object console.log(obj1); Output{ name: 'Rohit', city: 'Noida' } Explanation: Here, the { age, ...obj } syntax extracts the age property and assigns the remaining properties to a new object called obj. The original object remains unchanged.Using Reflect.deleteProperty The Reflect.deleteProperty method works similarly to the delete operator but provides a more standardized way to delete properties. It returns a Boolean indicating whether or not the deletion was successful. JavaScript let obj = { name: "Rohit", age: 24, city: "Noida" }; // Using Reflect.deleteProperty to // remove the 'city' property Reflect.deleteProperty(obj, 'city'); console.log(obj); Output{ name: 'Rohit', age: 24 } Which Approach Is Better in Different Cases?delete Operator: The delete operator is the most simple and widely used for removing a property from an object. It is the best choice when you need to directly mutate the original object.Object Destructuring: It is suitable if you want to create a new object without the specified property, leaving the original object unchanged. It is useful in functional programming where immutability is preferred.Reflect.deleteProperty: While less commonly used than the delete operator, Reflect.deleteProperty provides a consistent and predictable way to delete properties. It can be helpful when working with Reflect-based operations or if you need to handle failures in a more controlled way. Comment More infoAdvertise with us Next Article How to Remove a Property From JavaScript Object? P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-object JavaScript-Questions Similar Reads How to add and remove properties from objects in JavaScript ? We will try to understand how to add properties to an object and how to add or remove properties from an object in JavaScript.Before we go and see the addition and removal of properties from an object let us first understand the basics of an object in JavaScript.Object:An object in JavaScript is a c 6 min read How to check if a value is object-like in JavaScript ? In JavaScript, objects are a collection of related data. It is also a container for name-value pairs. In JavaScript, we can check the type of value in many ways. Basically, we check if a value is object-like using typeof, instanceof, constructor, and Object.prototype.toString.call(k). All of the ope 4 min read JavaScript - Convert Two-Dimensional Array Into an Object Here are the different methods to convert the two-dimensional array into an object in JavaScript.1. Using a for LoopThe simplest way to convert a two-dimensional array into an object is by iterating through the array using a for loop and assigning key-value pairs.JavaScriptconst a = [['name', 'Abhay 2 min read How to get all the methods of an object using JavaScript? In this article, we will learn how to get all the methods of an object using JavaScript. In JavaScript, we can get all the methods of an object by iterating over each object and checking if its property value is a function. An HTML document contains some methods and the task is to get all methods of 2 min read How to implement a filter() for Objects in JavaScript ? In this article, we will learn how to implement a filter() for Objects in JavaScript. In JavaScript, the filter() method is a built-in function for the array, not for the object. The filter() method outputs all the elements of an array that pass a specific test or satisfies a specific function. The 3 min read How to add a property to a JavaScript object using a variable as the name? In JavaScript, you can dynamically add a property to an object using a variable as the name. This allows you to create flexible and dynamic objects based on runtime values, enhancing code reusability and adaptability. There are several methods that can be used to add a property to a JavaScript objec 2 min read How to Create Dynamic Values and Objects in JavaScript? In JavaScript, you can choose dynamic values or variable names and object names and choose to edit the variable name in the future without accessing the array, Dynamic values and objects in JavaScript allow changing, accessing, or creating values and object properties at runtime for flexibility and 3 min read JavaScript - Print Object by id in an Array of Objects Here are the various methods to print objects by id in an array of objects in JavaScript1. Using Array.filter() MethodThe Array.filter() method, creates a new array containing only the object with the specified ID. JavaScriptconst a = [ { id: 1, name: "Alia" }, { id: 2, name: "Dua" }, { id: 3, name: 3 min read How to get the last item of JavaScript object ? In this article, we will learn how to get the last item of a Javascript object. Given a JavaScript object and the task is to get the last element of the JavaScript object. This can be done by the following methods: Using Object.keys() methodUsing for loopmethodApproach 1: Use Object.keys() method to 2 min read JavaScript- Add an Object to JS Array In JavaScript, arrays are used to store multiple values in a single variable, and objects are collections of properties and values. Sometimes, we may need to add an object to an array to manage data more effectively. These are the following ways to add an object to a JS array: Using JavaScript Array 4 min read Like