# Difference between array of objetcs and Array Object in javascript. Do you ever came to the term "array of objects" and confused it with "Array Object" or do the opposite. Both are totally different terms used to describe totally different concepts, so it's important to know the difference between them. In this article, we are going to talk about the difference between array of objects and an Array Object in javascript by taking some examples. ## Introduction An array of objects in javascript stands for an array holding collection of multiple objects as it's value, where Array Object is a predefined native Object that is also called an array which helps to store the collection of multiple types of data at a single place. Before understanding the difference between an array of objects and Array Object we have to understand about the array itself. ## Array in javascript Array in javascript is collection of multiple types of data at a single place, data can be number, string, boolean, function or any other types of data available in the javascript. We declare an empty array by opening and closing square brackets(`[]`), to add the values, we write it in between the square brackets(`[]`) seperated by commas. Value of an array are accessible using indexing which starts from index zero. Example of declaring an array- ```js let myArr = [1, true, "ankit", function() {return "myFun function"}]; console.log(myArr[1]) //Output => true ``` Output- ``` true ``` Above, we declared an array `myArr` and store the collection of multiple types of data, ex- number, boolean, string and function, as data values. Now, we know the basic of what is an array and how it works. Let's talk about the array of the objects. ## Array of objects in javascript Array of objects in javascript is just an array, but insted of having collection of multiple types of data as it's value, array of objects is only the collection of multiple objects as it's data values. ### Array of objects example- ```js let mySchool = [ { name: "your school name", address: "school address" }, { students: 500, teachers: 20 } ]; ``` In the above example, we declared an array of objects `mySchool` where we have collected some objects as it's data values. >**Note:** Above, we declared an array of objects, in the same way, we can declare an array of any data types available in javascript. ## Create an array of objects ## Array Object in javascript Array of Object is the other name for an array, which helps to store the collection of multiple types of data at a single place. In javascript everything is an object, that's the reason behind calling array, an Array Object in javascript. ## Create an array object **There are two ways to declare an array in javascript:** **1. Declare an array using `Array()` constructor** To declare an array using `Array` constructore we have to call the `Array()` constructor function by passing the array data values(seperated by comma) as parameter. Example of **declaring an array using `Array()` constructor**- ```javascript= let myArr = new Array("tom", 9, true, null); console.log(myArr); ``` Output- ``` ["tom", 9, true, null] ``` Above, we decalre an array `myArr` by calling the `Array()` constructor and passing the array data values as argument. **2. Using array literals `[]`** To declare an array using array literals we have to use the pair of opening and closing square brackets (`[]`) by passing the array data values(seperated by comma) in between these brackets. Declare an array using array literals (`[]`) is a prefered way to declare an array in javascript. Example of **declaring an array using array literals** `[]`- ```javascript= let myArr = ["tom", 9, true, null]; console.log(myArr[0]); ``` Output- ``` "tom" ``` Above, we declare an array `myArr` by using the array literals(`[]`) and there are three values inside the array seperated by comma. We have also printed the first value on console by accesing array indexing. ## Difference between array of objetcs and Array Object | Array of objetcs | Array Object | | -------- | -------- | | It is an array, holding collection of multiple objects as it's value. | Array of Object is the other name for an array, which helps to store the collection of multiple types of data at a single place. | | It can only have the objects as it's data values. | It can have anything as it's data values. | | Array of objects and an array can't be use interchangeably. | Array Object and array are often used interchangeably. | ## Conclusion: * Array of objects is an array having collection of objects as it's data values. * Array of Object is the other name for an array, which helps to store the collection of multiple types of data at a single place.