<!DOCTYPE html>
<html>
<head>
<title>Array - JavaScript | MDN</title>
<meta name="description" content="The Array object enables storing a collection of multiple items under a single variable name.">
</head>
<body>
<header>
<nav><a href="/">MDN</a></nav>
</header>
<main>
<h1>Array</h1>
<p>The <strong>Array</strong> object enables storing a collection of multiple items under a single variable name, and has members for performing common array operations.</p>
<h2 id="description" class="heading"><a class="heading-anchor" href="#description">Description</a></h2>
<p>In JavaScript, arrays aren't primitives but are instead Array objects with the following core characteristics:</p>
<ul>
<li><strong>JavaScript arrays are resizable</strong> and <strong>can contain a mix of different data types</strong>.</li>
<li><strong>JavaScript arrays are not associative arrays</strong> and so, array elements cannot be accessed using nonnumeric strings as indexes.</li>
<li><strong>JavaScript arrays are zero-indexed</strong>: the first element of an array is at index 0, the second is at index 1, and so on.</li>
</ul>
<h3 id="iterative_methods" class="heading"><a class="heading-anchor" href="#iterative_methods">Iterative methods</a></h3>
<p>Several methods take as arguments functions to be called back while processing the array. When these methods are called, the length of the array is sampled, and any element added beyond this length from within the callback is not visited.</p>
<h3 id="generic_array_methods" class="heading"><a class="heading-anchor" href="#generic_array_methods">Generic Array methods</a></h3>
<p>Array methods are always generic — they don't access any internal data of the array object. They only access the array elements through the length property and the indexed elements.</p>
<h2 id="constructor" class="heading"><a class="heading-anchor" href="#constructor">Constructor</a></h2>
<dl>
<dt><code>Array()</code></dt>
<dd>Creates a new Array object.</dd>
</dl>
<h2 id="static_methods" class="heading"><a class="heading-anchor" href="#static_methods">Static methods</a></h2>
<dl>
<dt><code>Array.from()</code></dt>
<dd>Creates a new Array instance from an iterable or array-like object.</dd>
<dt><code>Array.isArray()</code></dt>
<dd>Returns true if the argument is an array, or false otherwise.</dd>
<dt><code>Array.of()</code></dt>
<dd>Creates a new Array instance with a variable number of arguments.</dd>
</dl>
<h2 id="instance_methods" class="heading"><a class="heading-anchor" href="#instance_methods">Instance methods</a></h2>
<dl>
<dt><code>Array.prototype.at()</code></dt>
<dd>Returns the array item at the given index.</dd>
<dt><code>Array.prototype.concat()</code></dt>
<dd>Returns a new array that is the calling array joined with other array(s) and/or value(s).</dd>
<dt><code>Array.prototype.filter()</code></dt>
<dd>Returns a new array containing all elements of the calling array for which the provided filtering function returns true.</dd>
<dt><code>Array.prototype.find()</code></dt>
<dd>Returns the value of the first element in the array that satisfies the provided testing function, or undefined if no appropriate element is found.</dd>
<dt><code>Array.prototype.map()</code></dt>
<dd>Returns a new array containing the results of invoking a function on every element in the calling array.</dd>
<dt><code>Array.prototype.push()</code></dt>
<dd>Adds one or more elements to the end of an array, and returns the new length of the array.</dd>
<dt><code>Array.prototype.reduce()</code></dt>
<dd>Executes a user-supplied "reducer" callback function on each element of the array.</dd>
</dl>
</main>
<footer>
<p>Last modified: 2025-01-15</p>
</footer>
</body>
</html>