🚀 Day 7 / 30 - JavaScript Coding Practice Today’s challenge: Recreating the Array.map() functionality — without actually using it 👀 Problem: Apply a transformation function to each element of an array and return a new array. 💡 Key Insight: This problem helped me understand what’s happening under the hood of built-in methods like map(). 👉 Instead of relying on .map(), I used a loop to: Iterate through each element Apply the given function with both value & index Build a new transformed array Solution: var map = function (arr, fn) { let transArr = [] arr.forEach((element, i) => { transArr.push(fn(element, i) ?? element); }); return transArr; }; #JavaScript #DSA #CodingPractice #100DaysOfCode #FrontendDevelopment #ProblemSolving
Recreating Array.map() Functionality in JavaScript
More Relevant Posts
-
Understanding the Event Loop in JavaScript is a turning point for every developer. Many developers use async features like promises, setTimeout, or async/await daily — but very few truly understand what happens behind the scenes. I’ve written a detailed yet easy-to-understand article that breaks down: ✔ Call Stack ✔ Callback Queue ✔ Microtask Queue ✔ Execution Order If you want to strengthen your JavaScript fundamentals and avoid common async mistakes, this will definitely help. 👉 Read the full article: https://lnkd.in/gDhwvmUc I’d love to hear your thoughts — what was the hardest concept for you when learning the Event Loop? #JavaScript #SoftwareDevelopment #WebDevelopment #FrontendDevelopment #AsyncProgramming #Coding #TechLearning
To view or add a comment, sign in
-
Understanding JavaScript arrays changed how I think as a developer. Coming from a teaching background I thought coding was memorizing syntax. Feeling a level of guilt when I pulled out my cheat sheet. But working with arrays like .map( ) and .reduce( ) helped me make a lasting connection. It’s not about memorizing code. It’s about solving problems efficiently. Instead of looping manually, I can transform and analyze data in a much cleaner way. If you’re learning JavaScript, stick with it until it clicks! Now I focus less on memorizing and more on understanding patterns. #SoftwareDeveloper #Tech #FullStack #JavaScript #SoftwareEngineer #WebDevelopment #MERNStack
To view or add a comment, sign in
-
🚀 Understanding var, let, and const in JavaScript While learning JavaScript, one of the most important concepts I revisited is the difference between var, let, and const. It may look basic, but it plays a huge role in writing clean and bug-free code. 🔹 var - Function scoped - Can be re-declared and re-assigned - Can cause unexpected bugs due to scope leakage 🔹 let - Block scoped - Cannot be re-declared - Can be re-assigned 🔹 const - Block scoped - Cannot be re-declared or re-assigned - Must be initialized at the time of declaration 💡 One key takeaway: Use const by default, let when values need to change, and avoid var in modern JavaScript. Small concepts like these build a strong foundation for writing better and more predictable code. #JavaScript #WebDevelopment #Frontend #Coding #Learning #MERNStack #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Just Published: Map and Set in JavaScript https://lnkd.in/g-nAm7SZ Understanding Map and Set helps you write more efficient and cleaner JavaScript code. In this article, I covered: ✅ What Map is and how it stores key-value pairs ✅ What Set is and how it ensures unique values ✅ Difference between Map and Object ✅ Difference between Set and Array ✅ When to use Map and Set in real-world scenarios 💡 Learn how Map solves limitations of traditional objects and how Set automatically removes duplicates. If you're preparing for interviews or improving your JS fundamentals, this is a must-read! 🙏 Thanks to amazing mentors and community 🙌 Hitesh Choudhary Sir, Piyush Garg Sir, Akash Kadlag Sir, Suraj Kumar Jha Sir, Chai Aur Code #JavaScript #WebDevelopment #Coding #Frontend #FullStack #Programming #Developers #TechCommunity
To view or add a comment, sign in
-
-
Wrote a new blog on Synchronous vs Asynchronous JavaScript Covering: • What synchronous code actually means • How asynchronous code works behind the scenes • Blocking vs non-blocking execution • Why JavaScript needs async behavior • Real-world examples like API calls and timers • Problems caused by blocking code • A simple mental model of the event loop https://lnkd.in/g5pv2Wnz #JavaScript #WebDevelopment #FrontendDevelopment #AsyncJS #100DaysOfCode #Programming #Coding #Developers
To view or add a comment, sign in
-
🚀 JavaScript Event Loop Explained in a Simple Way JavaScript is a single-threaded language, but it still handles asynchronous tasks like API calls, timers, and events very efficiently. This is possible because of something called the Event Loop. Here’s a simple breakdown: 👉 When JavaScript runs code, it first executes everything in the Call Stack (synchronous code). 👉 If it encounters asynchronous tasks (like setTimeout, fetch requests, etc.), they are sent to the Web APIs. 👉 Once those tasks are completed, their callbacks go to the Callback Queue or Microtask Queue. 👉 The Event Loop continuously checks: “If the Call Stack is empty, push tasks from the queues into the Call Stack.” That’s how JavaScript handles async operations without blocking the main thread. 💡 Key takeaway: Even though JavaScript looks synchronous, the Event Loop makes asynchronous behavior possible. Still learning and exploring more core concepts like this every day. #JavaScript #WebDevelopment #Programming #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
Most developers use JavaScript every day… But very few truly understand how it actually executes code behind the scenes. That’s where the Event Loop comes in — the heart of JavaScript’s asynchronous behavior. At a high level: JavaScript is single-threaded. But it behaves like it can handle multiple things at once. How? Because of this powerful architecture 👇 • Call Stack → Executes synchronous code line by line • Microtask Queue → Handles Promises, async/await (high priority) • Macrotask Queue → Handles setTimeout, setInterval, I/O operations • Event Loop → Constantly checks and decides what runs next Here’s the game-changing concept: 👉 Microtasks ALWAYS run before Macrotasks That’s why: Promise resolves → runs immediately after current execution setTimeout → waits even if delay is 0 This small detail is the reason behind: • Unexpected output order • Async bugs • Performance differences • UI responsiveness If you’ve ever wondered: “Why is my code running in a different order than I expected?” The answer is almost always → Event Loop behavior Understanding this doesn’t just make you a better developer — It changes how you think about writing code. You stop guessing. You start predicting. And that’s where real engineering begins. 🚀 #JavaScript #EventLoop #AsyncJavaScript #WebDevelopment #FullStackDevelopment #Programming #SoftwareEngineering #TechDeepDive #CodingJourney JavaScript Mastery w3schools.com
To view or add a comment, sign in
-
-
🚀 Functions Deep Dive Today I didn’t just “learn functions”… I understood how JavaScript actually thinks. Here’s what I explored 👇 🔹 What is a Function A reusable block of code that makes programs cleaner and smarter. 🔹 Function Parameters & Arguments Turning static code into dynamic logic. 🔹 Arrow Functions (ES6) Cleaner syntax, less code, more power. 🔹 Default Parameters Handling missing inputs like a pro. 🔹 First-Class Functions 🔥 This changed everything for me: Functions in JavaScript are treated like values. ✔️ Stored in variables ✔️ Passed as arguments ✔️ Returned from other functions This is the foundation of: ➡️ Callbacks ➡️ Async JavaScript ➡️ React 💡 Biggest Realization: JavaScript isn’t just a language… It’s a system where functions are the core building blocks. 🧠 What I’m focusing on: • Strong fundamentals over shortcuts • Understanding > memorizing • Writing code daily 📌 Next Step: Higher-Order Functions + Real-world practice #javascript #webdevelopment #codingjourney #180daysofcode #frontenddevelopment #reactjs #programming #developers #learninpublic #softwareengineering #matadeenyadav #MatadeenYadav
To view or add a comment, sign in
-
-
🚀 Day 4 of my JavaScript Coding Practice Today’s problem: Two Sum var twoSum = function(nums, target) { const map = new Map(); // Store: { value : index } for (let i = 0; i < nums.length; i++) { const complement = target - nums[i]; // If the needed number is already in our map, we found the pair! if (map.has(complement)) { return [map.get(complement), i]; } // Otherwise, save the current number and its index map.set(nums[i], i); } return []; // Return empty if no pair is found }; 💡 Instead of using brute force (O(n²)), I used a HashMap approach to solve it in O(n) time. Key takeaway: Understanding how to trade space for time can significantly optimize performance. Small steps every day → Big improvements over time 📈 #JavaScript #DSA #CodingPractice #100DaysOfCode #FrontendDevelopment
To view or add a comment, sign in
-
-
Understanding JavaScript Execution Context changed how I debug code 👇 At first, JavaScript feels straightforward. But when things don’t behave as expected, execution context is usually where the answer lies. Every time a function runs, JavaScript creates a new execution context. Inside it: • Variables are created • Functions are stored • `this` is determined And all of this happens before the code actually executes. That’s why things like hoisting and scope behave the way they do. This behaves differently than many expect. Once I understood this, debugging became much clearer. Sometimes the problem isn’t the code, it’s understanding how JavaScript runs it. #JavaScript #ExecutionContext #FrontendDevelopment #SoftwareEngineering #Programming #LearningInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development