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)Disclaimer:This tool is provided βas isβ for informational and educational purposes only. Results may not be 100% accurate. ToolBird makes no warranties, express or implied, regarding the accuracy, reliability, or completeness of any output generated by this tool. This tool does not constitute professional, legal, financial, medical, or tax advice. Always consult a qualified professional for important decisions. By using this tool, you agree that ToolBird and its operators shall not be held liable for any damages, losses, or consequences arising from the use of this tool or reliance on its results. All processing occurs in your browser β we do not store, transmit, or access your data. Use at your own risk.