Reference · 42 entries
JavaScript Reference
The JavaScript reference: every built-in array, string and object method with syntax, the ECMAScript edition that added it, and examples you can run in your browser.
JavaScript (ES2026) Version history
JavaScript has no versions to install: features arrive in yearly ECMAScript editions (ES2015, ES2016, …) and browsers add them one by one. Each page shows the edition that introduced a feature, linked to the JavaScript version history. Examples run in your browser's own JavaScript engine; check browser support on MDN for features from the last year or two.
Array Methods
Every JavaScript array method, from at() to with(), with syntax, parameters and examples you can run. Shows which methods change the array and which return a copy.
| Name | Description |
|---|---|
array.at() | Return the element at an index, where negative indexes count from the end: arr.at(-1) is the last element. |
array.concat() | Return a new array that joins this array with other arrays or values. The original arrays are not changed. |
array.copyWithin() | Copy a slice of the array to another position in the same array, overwriting what's there. Changes the array in place. |
array.entries() | Return an iterator of [index, element] pairs, handy for looping with both the index and the value. |
array.every() | Return true if every element passes a test function. Stops at the first failure; an empty array returns true. |
array.fill() | Fill all or part of an array with a static value, changing it in place. Often used to create an array of defaults. |
array.filter() | Return a new array with only the elements that pass a test function. The original array is not changed. |
array.find() | Return the first element that passes a test function, or undefined if none does. |
array.findIndex() | Return the index of the first element that passes a test function, or -1 if none does. |
array.findLast() | Return the last element that passes a test function, searching from the end, or undefined if none does. |
array.findLastIndex() | Return the index of the last element that passes a test function, or -1 if none does. |
array.flat() | Return a new array with nested arrays flattened into it, one level deep by default or to a given depth. |
array.flatMap() | Map each element with a function, then flatten the result one level. Useful when one element becomes several. |
array.forEach() | Call a function once for each element. It returns undefined, so use map() when you need a new array. |
array.includes() | Return true if the array contains a value, using SameValueZero equality (so it finds NaN, unlike indexOf). |
array.indexOf() | Return the first index at which a value is found (using ===), or -1 if it isn't in the array. |
array.join() | Join all elements into one string, separated by commas or by a separator you choose. |
array.keys() | Return an iterator of the array's indexes, including indexes of empty slots. |
array.lastIndexOf() | Return the last index at which a value is found (using ===), searching backwards, or -1 if it isn't there. |
array.length | The number of elements in the array. Setting it shortens or extends the array. |
array.map() | Return a new array with the results of calling a function on every element. The original array is unchanged. |
array.pop() | Remove the last element from the array and return it. Changes the array; returns undefined if it is empty. |
array.push() | Add one or more elements to the end of the array and return the new length. Changes the array in place. |
array.reduce() | Reduce the array to a single value by running a reducer function on each element, carrying an accumulator along. |
array.reduceRight() | Like reduce(), but processes the array from the last element to the first. |
array.reverse() | Reverse the array in place and return it. Use toReversed() to get a reversed copy instead. |
array.shift() | Remove the first element of the array and return it, moving the other elements down. Returns undefined if empty. |
array.slice() | Return a shallow copy of part of the array, from start up to (not including) end. The original is not changed. |
array.some() | Return true if at least one element passes a test function. Stops at the first match; an empty array returns false. |
array.sort() | Sort the array in place and return it. Without a compare function elements are sorted as strings, so numbers need one. |