- 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 json element - JavaScript?
Let’s say the following is our JSON string −
var details = [ { customerName: "Chris", customerAge: 32 }, { customerName: "David", customerAge: 26 }, { customerName: "Bob", customerAge: 29 }, { customerName: "Carol", customerAge: 25 } ]
To remove JSON element, use the delete keyword in JavaScript.
Example
Following is the complete code to remove JSON element −
var details = [ { customerName: "Chris", customerAge: 32 }, { customerName: "David", customerAge: 26 }, { customerName: "Bob", customerAge: 29 }, { customerName: "Carol", customerAge: 25 } ] delete details[0].customerAge; console.log(details);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo211.js −
PS C:\Users\Amit\JavaScript-code> node demo211.js [ { customerName: 'Chris' }, { customerName: 'David', customerAge: 26 }, { customerName: 'Bob', customerAge: 29 }, { customerName: 'Carol', customerAge: 25 } ]
- Related Articles
- How to remove a specific element from a JSON Array in Java?
- Remove element by id in JavaScript?
- Search by id and remove object from JSON array in JavaScript
- Remove element from array referencing spreaded array in JavaScript
- Remove the child node of a specific element in JavaScript?
- How to remove every Nth element from an array JavaScript?
- JavaScript JSON Arrays
- JavaScript JSON HTML
- Convert JSON array into normal json in JavaScript
- How to remove last array element in JavaScript and return it?
- How to remove first array element in JavaScript and return it?
- How to remove a class name from an element with JavaScript?
- JavaScript JSON parse() Method
- How to convert JSON text to JavaScript JSON object?
- Convert JSON to another JSON format with recursion JavaScript

Advertisements