JavaScript Simplified: Array Methods

🚀 JavaScript Simplified Series — Day 12 Yesterday we learned Arrays… But storing data is not enough. 👉 Real power comes when you modify data Imagine this 👇 You have a shopping cart 🛒 Add item Remove item Update item Will you do everything manually? ❌ This is where Array Methods come in. 🔹 1. push() → Add item at the end let cart = ["Shoes", "T-shirt"] cart.push("Watch") console.log(cart) 👉 Output: ["Shoes", "T-shirt", "Watch"] 📌 Adds item at the end 🔹 2. pop() → Remove last item cart.pop() console.log(cart) 👉 Output: ["Shoes", "T-shirt"] 📌 Removes item from the end 🔹 3. unshift() → Add item at the beginning cart.unshift("Cap") console.log(cart) 👉 Output: ["Cap", "Shoes", "T-shirt"] 📌 Adds item at the start 🔹 4. shift() → Remove first item cart.shift() console.log(cart) 👉 Output: ["Shoes", "T-shirt"] 📌 Removes item from the start 🔥 Real Life Flow Shopping cart example: Add item → push() Remove last item → pop() Add priority item → unshift() Remove first item → shift() 🔥 Simple Summary push → add end pop → remove end unshift → add start shift → remove start 💡 Programming Rule Don’t manipulate data manually. Use built-in methods. If you want to learn JavaScript in a simple and practical way, you can follow these YouTube channels: • Rohit NegiHitesh Choudhary (Chai aur Code) 📌 Series Progress Day 1 → What is JavaScript Day 2 → Variables & Data Types Day 3 → Type Conversion & Operators Day 4 → Truthy & Falsy + Comparison Operators Day 5 → If Else + Switch + Ternary Day 6 → Loops Day 7 → Break + Continue + Nested Loops Day 8 → Functions Basics Day 9 → Arrow + Default + Rest Parameters Day 10 → Callback & Higher Order Functions Day 11 → Arrays Basics Day 12 → Array Methods (push, pop, shift, unshift) Day 13 → Array Iteration (Next Post) Follow for more 🚀 #JavaScriptSimplified #javascript #webdevelopment #coding #programming #learninpublic #100DaysOfCode #frontenddevelopment #devcommunity #codingjourney #softwaredeveloper #techcommunity #dailylearning #codeeveryday

To view or add a comment, sign in

Explore content categories