Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Iterating and printing a JSON with no initial key and multiple entries?
For iterating and printing, use forEach() loop in JavaScript.
Example
const details =[
{
"studentId":101,
"studentName": "John Doe",
},
{
"studentId":102,
"studentName": "David Miller",
},
];
details.forEach(obj=>{
console.log("StudentId="+obj.studentId);
console.log("StudentName="+obj.studentName);
})
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo174.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo174.js StudentId=101 StudentName=John Doe StudentId=102 StudentName=David Miller
Advertisements
