JavaScript Array Methods
Interactive reference for all JS array methods with live editable code examples. Edit, run, and learn.
Adding & Removing
Methods that add or remove elements
push()Adds elements to the endarr.push(...items)pop()Removes the last elementarr.pop()unshift()Adds elements to the beginningarr.unshift(...items)shift()Removes the first elementarr.shift()splice()Adds/removes elements at any positionarr.splice(start, deleteCount, ...items)Transformation
Methods that create new transformed arrays
map()Creates a new array by transforming each elementarr.map(callback(item, index, arr))filter()Creates a new array with elements that pass a testarr.filter(callback(item, index, arr))reduce()Reduces array to single value by accumulatingarr.reduce(callback(acc, item, index, arr), initialValue)flat()Flattens nested arrays to specified deptharr.flat(depth)flatMap()Maps then flattens one level deeparr.flatMap(callback)slice()Returns a shallow copy of a portionarr.slice(start, end)concat()Merges arrays togetherarr.concat(...arrays)Search & Test
Methods for finding elements and testing conditions
find()Returns first element that passes a testarr.find(callback(item, index, arr))findIndex()Returns index of first matching elementarr.findIndex(callback)indexOf()Returns first index of an elementarr.indexOf(item, fromIndex)includes()Checks if array contains an elementarr.includes(item, fromIndex)every()Tests if ALL elements passarr.every(callback)some()Tests if ANY element passesarr.some(callback)Sorting & Ordering
Methods that change element order
sort()Sorts elements in placearr.sort(compareFn)reverse()Reverses order of elements in placearr.reverse()toSorted()Returns a new sorted array (non-mutating)arr.toSorted(compareFn)toReversed()Returns a new reversed array (non-mutating)arr.toReversed()Iteration
Methods for looping over elements
forEach()Calls a function for each element (no return value)arr.forEach(callback(item, index, arr))entries()Returns iterator of [index, value] pairsarr.entries()keys()Returns iterator of indicesarr.keys()values()Returns iterator of valuesarr.values()Conversion
Methods that convert arrays to other types
join()Joins elements into a stringarr.join(separator)toString()Converts array to comma-separated stringarr.toString()Array.from()Creates array from iterable or array-likeArray.from(iterable, mapFn)Array.isArray()Checks if value is an arrayArray.isArray(value)Other
Additional useful methods
fill()Fills elements with a static valuearr.fill(value, start, end)copyWithin()Copies part of array to another location in same arrayarr.copyWithin(target, start, end)with()Returns new array with element replaced at indexarr.with(index, value)at()Returns element at index (supports negative)arr.at(index)Some links on this page are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you.
Recommended Products
AdAffiliate Disclosure: As an Amazon Associate, ToolBird earns from qualifying purchases. Links above are affiliate links — if you buy through them, we may earn a small commission at no extra cost to you.
Disclaimer: This tool is provided as-is for informational and educational purposes only.