Array of Objects
An array of objects is a array that contains the JavaScript Objects with different properties as elements stored at the different memory locations.
Example: The below code implements the Array of Objects in JavaScript.
Javascript
const objectsArray = [ { type: "Company" , name: "w3wiki" }, { type: "Cricketer" , name: "Virat Kohli" } ]; console.log( "Array of Objects: " , objectsArray); console.log( "First Object: " , objectsArray[0]); console.log( "Second Object: " , objectsArray[1]); |
Output
Array of Objects: [ { type: 'Company', name: 'w3wiki' }, { type: 'Cricketer', name: 'Virat Kohli' } ] First Object: { type: 'Company', name: 'w3wiki' } Second Object: { type: 'Cri...
Types of Arrays in JavaScript
A JavaScript array is a collection of multiple values at different memory blocks but with the same name. The values stored in an array can be accessed by specifying the indexes inside the square brackets starting from 0 and going to the array length – 1([0]…[n-1]).
A JavaScript array can be classified into multiple types:
Table of Content
- Numeric Array
- String Array
- Array of Arrays (2D Arrays)
- Array of Objects
- Mixed Arrays
- Array with empty values