- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove property for all objects in array in JavaScript?
To remove property, use delete keyword in JavaScript.
Example
Following is the code −
var values = [ { "firstName": "John", "lastName":"Smith" }, { "firstName": "David", "lastName":"Miller" }, { "firstName": "Adam", "lastName":"Smith" } ]; values.forEach(function(obj){ delete obj.lastName }); console.log(values);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo312.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo312.js [ { firstName: 'John' }, { firstName: 'David' }, { firstName: 'Adam' } ]
- Related Articles
- Remove array duplicates by property - JavaScript
- How to remove all blank objects from an Object in JavaScript?
- Remove duplicates from a array of objects JavaScript
- How to remove duplicate property values in array – JavaScript?
- Sum of array object property values in new array of objects in JavaScript
- Add property to common items in array and array of objects - JavaScript?
- Filter array of objects by a specific property in JavaScript?
- Retrieve property value selectively from array of objects in JavaScript
- Sort array of objects by string property value in JavaScript
- JavaScript Bubble sort for objects in an array
- Checking existence of all continents in array of objects in JavaScript
- Sorting an array objects by property having null value in JavaScript
- Remove all objects from the Queue in C#
- Remove all objects from the Stack in C#
- Sorting an array of objects by property values - JavaScript

Advertisements