Sonjib Chetry’s Post

🚀 Day 89/90 – #90DaysOfJavaScript Topic covered: Array.findIndex() & Array Creation Methods in JavaScript ✅ findIndex() in JavaScript 👉 Returns index of first matching element 👉 Returns -1 if no match 👉 Stops when match found (efficient) 👉 find() returns value, findIndex() returns position 👉 Useful for searching, updating, removing array items ✅ Array Length & Sparse Arrays 👉 .length → total elements count 👉 Arrays can have empty slots (sparse arrays) 👉 Empty slot ≠ undefined (JS skips empty slots in many methods) ✅ Array Creation Methods (Important!) ✅ new Array(n) 👉 Creates empty slots 👉 Not directly iterable (map/forEach skip) ✅ Array.from({ length: n }) 👉 Creates undefined values 👉 Fully iterable ✅ new Array(n).fill(value) 👉 Fills array with a value 👉 Best for initializing with defaults 🎯 Key Takeaways 👉 Use findIndex() when you need the index 👉 new Array(n) → reserved space (empty slots) 👉 Array.from() → iterable slots 👉 .fill() → pre-populate values 🛠️ Access my GitHub repo for all code and explanations: 🔗 https://lnkd.in/dfNxZfyc Let’s learn together! Follow my journey to #MasterJavaScript in 90 days! 🔁 Like, 💬 comment, and 🔗 share if you're learning too. #JavaScript #WebDevelopment #CodingChallenge #Frontend #JavaScriptNotes #MasteringJavaScript #GitHub #LearnInPublic

To view or add a comment, sign in

Explore content categories