JavaScript Array

Beginner
⏱️ 15 min read
📚 Updated: Jul 2026
🎯 39 Tutorials
Reference

What You’ll Learn

Arrays store ordered lists of values in JavaScript. Built-in methods let you add, remove, search, and transform data without reinventing loops every time. This hub links to 39 method tutorials, each with syntax, five try-it examples, and FAQs.

01

Add / remove

push, pop, shift

02

Search

find, includes

03

Transform

map, filter

04

Aggregate

reduce, some

05

Immutable

slice, concat

06

39 guides

Full index

Introduction

JavaScript arrays are versatile collections for storing lists of numbers, strings, objects, or mixed types. The language ships with dozens of helper methods on Array.prototype so you can manipulate data declaratively—often in one readable chain instead of manual for loops.

What Are Array Methods?

An array method is a function you call on an array (or on the Array constructor for static helpers). Some methods mutate the original array; others return a new array or value and leave the source untouched. Knowing which is which prevents subtle bugs.

💡
Beginner Tip

Start with push(), pop(), length, and bracket notation arr[0]. Then learn map(), filter(), and find()—they appear in almost every real-world codebase.

Mutating vs Non-Mutating

  • Mutatingpush(), splice(), sort(), reverse() change the array in place.
  • Non-mutatingmap(), filter(), slice(), concat() return new data.
  • StaticArray.from(), Array.isArray(), Array.of() live on the constructor, not instances.

📝 Syntax

Call an instance method on an array variable:

JavaScript
const fruits = ["apple", "banana", "cherry"];

fruits.push("date");           // mutates — adds to end
const upper = fruits.map(f => f.toUpperCase());  // new array

Method categories

CategoryExample methodsPurpose
Access & lengthat(), slice()Read elements by index
Add / removepush(), pop(), splice()Change array size
Searchincludes(), find(), indexOf()Locate values
Transformmap(), filter(), flat()Build new arrays
Aggregatereduce(), some(), every()Summarize or test all items

⚡ Quick Reference

GoalMethodMutates?
Add to endpush(item)Yes
Remove from endpop()Yes
Copy a portionslice(start, end)No
Transform each itemmap(fn)No
Keep matching itemsfilter(fn)No
Sum to one valuereduce(fn, init)No

When to Use Which Methods

  • Stack operationspush() / pop() for last-in-first-out patterns.
  • Queue operationspush() + shift() (or use a dedicated queue structure for large data).
  • Display listsmap() to render UI from raw data.
  • User filtersfilter() to show only matching rows.
  • Totals & countsreduce() to sum prices or build objects.

👀 Sample Array

A typical array of strings with zero-based indexes:

[ "JavaScript", "Python", "Java" ] → length: 3 → at(-1): "Java"

Array Method Tutorial Index

Search by method name or browse by category. Every tutorial includes syntax, five try-it examples, and FAQs.

Getting Started

6 tutorials

Essential methods for reading, adding, and removing elements.

MethodDescriptionTutorial
at()Retrieves an element at a specified index, including negative offsets from the end.Open
push()Adds one or more elements to the end and returns the new length.Open
pop()Removes and returns the last element, mutating the array.Open
shift()Removes and returns the first element, shifting others down.Open
unshift()Adds elements to the beginning and returns the new length.Open
slice()Returns a shallow copy of a portion without mutating the original.Open

Transform & Aggregate

6 tutorials

Map, filter, flatten, and reduce data into new shapes.

MethodDescriptionTutorial
map()Creates a new array by transforming each element with a callback.Open
filter()Creates a new array with elements that pass a test function.Open
flat()Flattens nested arrays into a single-level array.Open
flatMap()Maps each element then flattens the result by one level.Open
reduce()Reduces the array to a single value by applying a callback left to right.Open
reduceRight()Like reduce(), but processes elements from right to left.Open

In-Place Changes

5 tutorials

Methods that modify the original array directly.

MethodDescriptionTutorial
splice()Adds, removes, or replaces elements at a given index in place.Open
sort()Sorts elements in place using an optional compare function.Open
reverse()Reverses element order in place and returns the same array.Open
fill()Fills all or part of an array with a static value, mutating the array.Open
copyWithin()Copies a sequence of elements within the array to another index in place.Open

Iteration

4 tutorials

Loop over elements or expose iterators.

MethodDescriptionTutorial
forEach()Runs a callback for each element; does not return a new array.Open
entries()Returns an iterator of [index, value] pairs for each element.Open
keys()Returns an iterator of index keys for the array.Open
values()Returns an iterator of the array element values.Open

Combine & Immutable Updates

2 tutorials

Merge arrays or return updated copies without mutation.

MethodDescriptionTutorial
concat()Combines two or more arrays into a new array without mutating the originals.Open
with()Returns a new array with one index replaced; does not mutate the original.Open

String Conversion

4 tutorials

Turn arrays into readable strings.

MethodDescriptionTutorial
join()Joins all elements into a string with an optional separator.Open
toString()Returns a comma-separated string of the array elements.Open
toLocaleString()Returns a locale-aware string representing the array.Open
valueOf()Returns the primitive value of the array (the array itself).Open

Static Methods

3 tutorials

Array constructor helpers — not called on an instance.

MethodDescriptionTutorial
Array.from()Creates an array from an iterable or array-like object.Open
Array.isArray()Returns true if the value is an array, false otherwise.Open
Array.of()Creates a new array from the arguments you pass in.Open

Examples Gallery

Five starter snippets combining common array methods. Open linked tutorials for full guides and try-it labs.

📚 Transform Data

Filter, map, and chain methods for clean data pipelines.

Example 1 — Filter Even Numbers and Square Them

Chain filter() and map() to transform a list in two steps.

JavaScript
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const evenSquares = numbers
  .filter((num) => num % 2 === 0)
  .map((even) => even ** 2);

console.log("Original:", numbers);
console.log("Even squares:", evenSquares);
filter() Tutorial

How It Works

filter() keeps only even numbers. map() squares each survivor. The original numbers array is unchanged.

Example 2 — Add and Remove with push() and pop()

Mutate a stack-like array at the end.

JavaScript
const stack = ["first", "second"];

stack.push("third");
console.log("After push:", stack);

const removed = stack.pop();
console.log("Removed:", removed);
console.log("After pop:", stack);
push() Tutorial

How It Works

push() returns the new length and adds to the end. pop() removes the last element and returns it.

Example 3 — Find the First Match

Use find() to locate an object by property value.

JavaScript
const users = [
  { id: 1, name: "Ada" },
  { id: 2, name: "Grace" },
  { id: 3, name: "Alan" }
];

const match = users.find((user) => user.name === "Grace");
console.log(match);
find() Tutorial

How It Works

find() stops at the first element where the callback returns true. If nothing matches, it returns undefined.

Example 4 — Sum Values with reduce()

Fold an array of numbers into a single total.

JavaScript
const prices = [9.99, 14.5, 4.25, 22.0];

const total = prices.reduce((sum, price) => sum + price, 0);
console.log("Total:", total.toFixed(2));
reduce() Tutorial

How It Works

The callback receives an accumulator and the current item. Starting from 0, each price adds to the running sum.

Example 5 — Sort Strings Alphabetically

sort() orders elements in place; pass a compare function for numbers.

JavaScript
const languages = ["JavaScript", "Python", "Java", "Ruby"];

languages.sort();
console.log(languages);
sort() Tutorial

How It Works

Default sort() converts elements to strings and compares UTF-16 code units. For numeric sort, use (a, b) => a - b.

💬 Usage Tips

  • Chain thoughtfullyfilter().map() reads left to right; each step returns a new array.
  • Prefer const — arrays are mutable objects; const arr = [] still allows push().
  • Spread for copies[...arr] or arr.slice() before mutating if you need a clone.
  • Callback parameters — most iterators receive (element, index, array).
  • Search this index — jump to any of 39 method pages above.

⚠️ Common Pitfalls

  • sort() without compare — numeric arrays sort lexically: [10, 2, 1].sort()[1, 10, 2].
  • Mutating while iterating — avoid splice() inside a forEach() over the same array.
  • Sparse arrays — holes skip callbacks in map() and forEach().
  • forEach vs break — you cannot break out of forEach(); use a for...of loop or some().
  • Reference equalityincludes() uses SameValueZero; objects match by reference, not deep equality.

🧠 How Array Methods Run

1

Call on an array

Invoke arr.method(args) or Array.from(iterable) for static helpers.

Invoke
2

Engine processes elements

Iterators walk indexes; some methods skip holes or stop early (find, some).

Iterate
3

Return a result

New array, boolean, single value, iterator, or mutated original—depends on the method.

Return
=

Composable pipelines

Chain non-mutating methods for readable data transformations in apps and APIs.

Browser Support

Core methods like push(), map(), filter(), and reduce() work in every modern browser and Node.js. Newer methods (at(), findLast(), with()) have dedicated notes on their tutorial pages.

Baseline · ES5–ES2023

Array.prototype methods

Most methods are production-safe in Chrome, Firefox, Safari, Edge, IE 9+, and all modern Node.js versions. Check individual tutorials for ES2022+ additions.

99% Core methods
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
Array methods Excellent

Bottom line: Safe to use core methods everywhere except very old IE8 environments. Polyfill or check individual pages for ES2022+ APIs like at() and with().

🎉 Conclusion

JavaScript array methods turn plain lists into powerful data tools. Start with Getting Started tutorials, then use the searchable index to explore all 39 guides.

Each method page includes syntax, five try-it examples, browser support, and FAQs. Combine methods in chains to keep application code short and expressive.

💡 Best Practices

✅ Do

  • Learn mutating vs non-mutating methods
  • Use Array.isArray() for type checks
  • Pass compare functions to sort() for numbers
  • Prefer slice() over splice() for copies
  • Read method docs before chaining unfamiliar APIs

❌ Don’t

  • Assume sort() orders numbers correctly by default
  • Mutate arrays you are iterating over
  • Use forEach() when you need a returned array
  • Rely on delete arr[i] to remove items — use splice()
  • Memorize all 39 names at once

Key Takeaways

Knowledge Unlocked

Five things to remember about array methods

Your gateway to 39 method tutorials.

5
Core concepts
+ 02

Mutate

push, splice

In-place
map 03

Transform

map, filter

New data
? 04

Search

find, includes

Lookup
39 05

Index

Search all

Ref

❓ Frequently Asked Questions

Array methods are built-in functions on Array.prototype (or the Array constructor) that help you read, add, remove, transform, and search elements. Examples include push(), map(), filter(), and reduce().
Methods like push(), pop(), shift(), unshift(), splice(), sort(), reverse(), fill(), and copyWithin() change the array in place. Methods like map(), filter(), slice(), and concat() return a new array or value without modifying the original.
map() runs a callback on each element and returns a new array of results. forEach() also runs a callback for each element but returns undefined — use it for side effects like logging, not for building a new array.
Use find() when you need the first matching element (or undefined). Use filter() when you need every element that matches, returned as a new array.
Use Array.isArray(value). It is more reliable than typeof because typeof [] returns 'object'.
Read the overview, try the five examples, then open at() or push() from Getting Started. Use the search box to jump to any of the 39 method tutorials.
Did you know?

Method chaining works because map(), filter(), and slice() each return a new array. You can write arr.filter(fn).map(fn) in one expression without temporary variables.

Start Your First Method Tutorial

Open at() or push() from Getting Started, or search the full index above.

at() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful