🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
July 28, 2026 - The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations. In JavaScript, arrays aren't primitives but are instead Array objects with the following core characteristics:
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
You should use arrays when you want the element names to be numbers. JavaScript has a built-in array constructor new Array().
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Arrays
An array is a special kind of object. The square brackets used to access a property arr[0] actually come from the object syntax. That’s essentially the same as obj[key], where arr is the object, while numbers are used as keys.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Indexed_collections
Indexed collections - JavaScript | MDN
2 weeks ago - For example, consider an array called emp, which contains employees' names indexed by their numerical employee number. So emp[0] would be employee number zero, emp[1] employee number one, and so on. JavaScript does not have an explicit array data type. However, you can use the predefined Array ...
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
The length property returns the length (size) of an array.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-arrays
JavaScript Arrays - GeeksforGeeks
In JavaScript, an array is an ordered list of values.
Published: 3 weeks ago
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › how-to-declare-an-array-in-javascript-creating-an-array-in-js
How to Declare an Array in JavaScript – Creating an Array in JS
November 7, 2024 - It stores multiple values and elements in one variable. These values can be of any data type — meaning you can store a string, number, boolean, and other data types in one variable....
🌐
Code Institute
codeinstitute.net › blog › javascript › javascript arrays
Javascript Arrays: A Guide - Code Institute DE
December 20, 2022 - JavaScript arrays are types of objects that are data collections, but you should think of them more as displays. This guide has you covered.
🌐
Medium
davitdvalashvili1996.medium.com › javascript-array-methods-your-complete-guide-372b9c6f12cd
JavaScript Array Methods: Your Complete Guide | by DavitDvalashvili | Medium
May 18, 2024 - In JavaScript, an array is a special type of object used to store and organize multiple values. Arrays enable you to group values under a single variable name, facilitating the management and manipulation of data collections.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Arrays
Arrays - Learn web development | MDN
In this lesson we'll look at arrays — a neat way of storing a list of data items under a single variable name. Here we look at why this is useful, then explore how to create an array, retrieve, add, and remove items stored in an array, and more besides.
🌐
Reddit
reddit.com › r/learnprogramming › javascript arrays arent actually arrays at all?
r/learnprogramming on Reddit: JavaScript arrays arent actually arrays at all?
February 12, 2026 -

So I have been learning computer science in college and getting specialized in web development just so I can get a better chance of landing an entry level job and I ran across something that I have been confused about. So in my understanding from my CS courses, an array is a contiguous composite data structure which holds homogeneous values which are ordered with an index. However in JS, arrays are composite data structures which hold heterogeneous values and are ordered with an index. Would an array in JS be closer to a record as far as data structures go or am I putting the cart before the horse in the importance of the allowance of more than one data structure? Is it more important that arrays are index-based by their definition more than it is important that they are homogeneous?

Any and all help would be great, thanks!!

Top answer
1 of 8
129

Nobody seems to be explaining the difference between an array and an object.

[] is declaring an array.

{} is declaring an object.

An array has all the features of an object with additional features (you can think of an array like a sub-class of an object) where additional methods and capabilities are added in the Array sub-class. In fact, typeof [] === "object" to further show you that an array is an object.

The additional features consist of a magic .length property that keeps track of the number of items in the array and a whole slew of methods for operating on the array such as .push(), .pop(), .slice(), .splice(), etc... You can see a list of array methods here.

An object gives you the ability to associate a property name with a value as in:

var x = {};
x.foo = 3;
x["whatever"] = 10;
console.log(x.foo);      // shows 3
console.log(x.whatever); // shows 10

Object properties can be accessed either via the x.foo syntax or via the array-like syntax x["foo"]. The advantage of the latter syntax is that you can use a variable as the property name like x[myvar] and using the latter syntax, you can use property names that contain characters that Javascript won't allow in the x.foo syntax.

A property name can be any string value.


An array is an object so it has all the same capabilities of an object plus a bunch of additional features for managing an ordered, sequential list of numbered indexes starting from 0 and going up to some length. Arrays are typically used for an ordered list of items that are accessed by numerical index. And, because the array is ordered, there are lots of useful features to manage the order of the list .sort() or to add or remove things from the list.

2 of 8
19

When you declare

var a=[];

you are declaring a empty array.

But when you are declaring

var a={};

you are declaring a Object .

Although Array is also Object in Javascript but it is numeric key paired values. Which have all the functionality of object but Added some few method of Array like Push,Splice,Length and so on.

So if you want Some values where you need to use numeric keys use Array. else use object. you can Create object like:

var a={name:"abc",age:"14"}; 

And can access values like

console.log(a.name);
🌐
Medium
medium.com › @teamtechsis › master-javascript-arrays-13e06b9af769
Master JavaScript Arrays. All-in-one starter guide to JavaScript… | by Natasha Ferguson | Medium
November 25, 2022 - An Array object is a JavaScript built-in object that can store multiple items of various data types in individual elements. An array is created by assigning [ ] square brackets to a variable which can optionally contain a comma-separated list ...
🌐
Mimo
mimo.org › glossary › javascript › arrays
Learn how to Use JavaScript Arrays: Create, Filter, Sort
In JavaScript, an array is a data structure that allows you to store multiple values in a single variable.
🌐
Programiz
programiz.com › javascript › array
JavaScript Array (with Examples)
In JavaScript, an array is an object that can store multiple values at once. In this tutorial, you will learn about JavaScript arrays with the help of examples.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-array-handbook
JavaScript Array Handbook – Learn How JS Array Methods Work With Examples and Cheat Sheet
August 31, 2023 - We'll cover the specific rules ... ... In JavaScript, an array is implemented as an object that can have a group of items, elements, or values as an ordered collection....
🌐
Medium
medium.com › @erickanginyi › all-about-javascript-arrays-97292ef9a785
All About (JavaScript) Arrays
September 17, 2021 - An array can be defined as an ordered, list-like data structure. They’re a special type of JavaScript object that is represented by square brackets [], with the indexed data inside being separated by commas.