Unit 2: Functions, Data Structures & ArraysLesson #4 / 10

Lesson 4: Arrays & Core Mutation Methods

Er. Manoj Kumar โ€” AuthorEr. Manoj Kumarโ€ขLast Updated: 26 Aug, 2026

1. JavaScript Array Fundamentals

Arrays are ordered list collections indexed starting at position 0.

  • push(item): Appends item to end.
  • pop(): Removes and returns the last item.
  • unshift(item): Inserts item at index 0.
  • shift(): Removes and returns the first item.
  • includes(item): Checks if an item exists in the array (returns boolean).
  • โŠžHTML5 Web Code (index.html)
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>JS Array Methods</title>
    </head>
    <body style="background:#17181c; color:#fff; font-family:Arial; padding:30px;">
    <h2>Tech Stack Array</h2>
    <p id="array-output"></p>
    <script>
    const techStack = ["HTML5", "CSS3", "JavaScript"];
    techStack.push("React");
    techStack.push("Node.js");
    document.getElementById("array-output").innerHTML =
    "<strong>Items:</strong> " + techStack.join(" &bull; ") + "<br>" +
    "<strong>Total Technologies:</strong> " + techStack.length;
    </script>
    </body>
    </html>

    Interactive Knowledge Check

    Test your understanding of Lesson #4 concepts

    Which method adds one or more elements to the END of an array and returns the new length?