An Array is an ordered, zero-indexed list of values. Arrays in JavaScript are dynamic: they can grow or shrink in size and hold any mixture of data types (strings, numbers, objects, even other arrays).
Git, games, and web forms frequently add and remove list items. JavaScript provides four primary stack/queue methods:
.includes()Checks if an item exists; returns true or false:
.indexOf()Returns index of item, or -1 if not found:
.slice() vs. .splice() (Crucial Difference!)| Method | Mutates Original Array? | Purpose |
|---|---|---|
.slice(start, end) | NO (Pure) | Extracts a shallow copy of a portion of the array |
.splice(start, deleteCount, ...items) | YES (Mutates) | Deletes, replaces, or inserts items in place! |
.join()arr.push("item") do?arr.shift() do?arr.slice() and arr.splice()?const arr = ["A", "B", "C"], what does arr.indexOf("D") return?["2026", "09", "15"] with hyphens into a string "2026-09-15"?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Arrow Functions (Basic) | Object Basics and Properties |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.