Array.from() creates a new Array from any iterable or array-like value, with optional mapFn and thisArg for inline transformation during conversion.
Reference
Array Methods
Methods available on every JavaScript Array instance.
- Array.from()
- Array.fromAsync()
Array.fromAsync() creates a Promise that resolves to a new array from an async iterable, iterable, or array-like input.
- Array.prototype.at()
Array.prototype.at() accesses array elements by positive or negative index, counting from the end when negative. Returns undefined when out of bounds.
- Array.prototype.concat()
Array.prototype.concat() merges arrays without mutation. Learn syntax, parameters, and practical patterns for concatenating arrays and values in JavaScript.
- Array.prototype.copyWithin()
copyWithin() shifts array elements to another index in place. Covers syntax, negative indices, rotation, and overwrite behavior with no new allocation.
- Array.prototype.entries()
Array.prototype.entries() returns a new iterator yielding [index, value] pairs for each element, making index-aware iteration straightforward in for...of loops.
- Array.prototype.every()
Learn Array.prototype.every(): tests if all elements pass a condition, returns a boolean, and short-circuits on the first failing element.
- Array.prototype.fill()
Array.prototype.fill() replaces array elements with a static value. Covers negative indices, the object reference trap, and typed array support.
- Array.prototype.filter()
Array.prototype.filter() returns a new array of elements that pass a callback test. Use it to filter by condition, remove falsy values, and deduplicate.
- Array.prototype.find()
Array.prototype.find() returns the first array element that satisfies a testing function. Returns undefined when no element matches the condition.
- Array.prototype.findIndex()
Array.prototype.findIndex() returns the index of the first array element that passes a test, or -1 if none do. Covers patterns and how it differs from find().
- Array.prototype.findLast()
Array.prototype.findLast() searches an array from the end and returns the last element that matches a testing function, or undefined.
- Array.prototype.findLastIndex()
Array.prototype.findLastIndex() searches an array in reverse and returns the index of the last element that matches a testing function, or -1 if none matches.
- Array.prototype.flat()
Array.prototype.flat() flattens nested arrays to a specified depth, returning a new array with sub-array elements concatenated into one level.
- Array.prototype.flatMap()
Array.prototype.flatMap() combines map and flatten in one pass. Covers syntax, filter-and-map patterns, depth limits, performance over chaining map().flat().
- Array.prototype.forEach()
Array.prototype.forEach() runs a callback for every array element. Returns undefined, cannot break early, and does not await async callbacks.
- Array.prototype.from()
Array.prototype.from() creates a shallow-copied array from array-like or iterable objects. Accepts a map function to transform elements during conversion.
- Array.prototype.includes()
Array.prototype.includes() checks if an array contains a value, returning a boolean. Handles NaN correctly and accepts an optional fromIndex.
- Array.prototype.indexOf()
Array.prototype.indexOf() finds the first position of a value in an array, returning the index or -1 when the element is not present.
- Array.prototype.isArray()
Use Array.isArray() to reliably detect array values in JavaScript. Handles cross-realm arrays where instanceof fails, with safe type guards for API validation.
- Array.prototype.join()
Array.prototype.join() concatenates all array elements into a single string with an optional custom separator. Returns an empty string for empty arrays.
- Array.prototype.keys()
Array.prototype.keys() returns an iterator that yields each index of an array, making it straightforward to iterate positions in for...of loops.
- Array.prototype.lastIndexOf()
Array.prototype.lastIndexOf() searches an array from right to left and returns the last index where a given element appears, or -1 if it is not found.
- Array.prototype.map()
Array.prototype.map() creates a new array by running a function on every element and collecting the results. Transform data without mutating the original.
- Array.prototype.of()
Array.of() creates a new Array from variadic arguments, treating each as an element — avoiding the number-as-length gotcha in the Array constructor.
- Array.prototype.pop()
Array.prototype.pop() removes the last element from an array and returns it. An O(1) mutating method for stacks, undo systems, and LIFO data structures.
- Array.prototype.push()
Array.prototype.push() appends elements to the end of an array, returning the new length. Covers syntax, patterns, performance, and immutable alternatives.
- Array.prototype.reduce()
Array.prototype.reduce() accumulates array elements into a single value via a callback — ideal for summing, grouping, and data transformation.
- Array.prototype.reduceRight()
Array.prototype.reduceRight() reduces an array from right to left into a single value — ideal for function composition and right-associative operations.
- Array.prototype.reverse()
Reverses an array in place and returns the same array reference. For an immutable reversed copy, use toReversed() instead.
- Array.prototype.shift()
Array.prototype.shift() removes and returns the first element of an array. Covers queue patterns, performance tradeoffs, and shift() vs pop().
- Array.prototype.some()
Array.prototype.some() tests whether at least one array element passes a callback. Returns true on the first match, false if no element passes.
- Array.prototype.sort()
Sorts the elements of an array in place and returns the same array reference. Pass a compare function for numeric or custom order.
- Array.prototype.splice()
Array.prototype.splice() adds, removes, or replaces array elements at any position and returns deleted elements. Covers patterns and toSpliced().
- Array.prototype.toReversed()
Array.prototype.toReversed() returns a new array with elements in reversed order, leaving the original unchanged. Part of the ES2023 immutable array methods.
- Array.prototype.toSorted()
Array.prototype.toSorted() returns a new sorted array without mutating the original. The immutable counterpart to sort(), introduced in ES2023.
- Array.prototype.toSpliced()
Array.prototype.toSpliced() returns a new array with elements removed, inserted, or replaced at a given index, leaving the original unchanged.
- Array.prototype.toString()
Array.prototype.toString() returns a comma-separated string of array elements calling toString() on each. Covers implicit coercion, null handling, and join().
- Array.prototype.unshift()
Array.prototype.unshift() prepends elements to the beginning of an array and returns the new length. Covers patterns, performance, and immutable alternatives.
- Array.prototype.values()
Array.prototype.values() returns a new Array Iterator that yields values for each index. Use it with for...of loops, spread syntax, and iterator patterns.
- Array.prototype.with()
Array.prototype.with() replaces the element at a given index in a new array, preserving the original. Part of ES2023's immutable array methods.
- Object.groupBy()
Object.groupBy() groups iterable elements into a null-prototype object, keyed by the string or symbol returned from a callback.