

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript creating an array from JSON data?
To create an array from JSON data, use the concept of map() from JavaScript. Let’s say the following is our data −
const studentDetails =[ { name : "John" }, { name : "David" }, { name : "Bob" } ];
Following is the code to create an array from the above data −
Example
const studentDetails =[ { name : "John" }, { name : "David" }, { name : "Bob" } ]; const ListOfStudentName = studentDetails.map(({name:actualValue})=>actualValue); console.log(ListOfStudentName);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo82.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo82.js [ 'John', 'David', 'Bob']
- Related Questions & Answers
- From JSON object to an array in JavaScript
- How to read data from JSON array using JavaScript?
- Creating an associative array in JavaScript?
- Create array from JSON object JavaScript
- JavaScript Convert an array to JSON
- Build tree array from JSON in JavaScript
- JavaScript: create an array of JSON objects from linking two arrays
- Creating an associative array in JavaScript with push()?
- Calculate average from JSON data based on multiple filters JavaScript
- Creating hierarchical JSON in MongoDB?
- Convert JSON array into normal json in JavaScript
- Formatting dynamic json array JavaScript
- Regroup JSON array in JavaScript
- Creating an array of objects based on another array of objects JavaScript
- Transform data from a nested array to an object in JavaScript
Advertisements