 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 Adding array name property to JSON object [ES5] and display in Console?
Following is our object −
var customerDetails ={    "customerFirstName":"David",    "customerLastName":"Miller",    "customerAge":21,    "customerCountryName":"US" }; Now, create a new array and use push() function. Following is the code −
Example
var customerDetails ={    "customerFirstName":"David",    "customerLastName":"Miller",    "customerAge":21,    "customerCountryName":"US" }; var customerObjectToArray = []; customerObjectToArray.push(customerDetails); console.log(customerObjectToArray); To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo125.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo125.js [    {       customerFirstName: 'David',       customerLastName: 'Miller',       customerAge: 21,       customerCountryName: 'US'    } ]Advertisements
 