Today I practiced the difference between map(), filter(), and forEach() in JavaScript. map() creates a new array by transforming each element of the original array. filter() creates a new array with elements that satisfy a specific condition. forEach() simply runs a function for each element and does not return a new array. Understanding these methods makes working with arrays much easier and cleaner. #JavaScript #WebDevelopment #ArrayMethods #LearningJourney
Mastering map(), filter(), and forEach() in JavaScript
More Relevant Posts
-
📚 Today I Learned: Scope Chain in JavaScript The scope chain in JavaScript is used to resolve variable values. When a variable is used, JavaScript looks for it in a specific order. 🔹 How it works: 1️⃣ JavaScript first checks the current scope. 2️⃣ If the variable is not found, it checks the outer (parent) scope. 3️⃣ This process continues until it reaches the global scope. 💻 Example: let a = 10; function outer() { let b = 20; function inner() { let c = 30; console.log(a, b, c); } inner(); } outer(); ✅ The inner() function can access c, b, and a because of the scope chain. #javascript #webdevelopment #frontenddeveloper #learninginpublic
To view or add a comment, sign in
-
🚀 Day 8/21 – JavaScript DOM Project Built a Live Search Filter using JavaScript DOM manipulation. 🛠 Features implemented: ✅ Real-time search filtering ✅ Dynamic DOM updates on user input ✅ Case-insensitive search logic ✅ Improved user experience with instant results 💡 Key Learning: Using the input event and DOM manipulation makes it possible to build real-time interactive search features. #Day8 #JavaScript #DOM #FrontendDevelopment #LearnInPublic
To view or add a comment, sign in
-
-
💡 JavaScript Practice — Counting Vowels A small problem, but a good test of logic: 👉 Count the number of vowels in a string Here’s my solution: const str = "javascript"; const vowels = "aeiouAEIOU"; let count = 0; for (let letter of str) { for (let vowel of vowels) { if (letter === vowel) count++; } } console.log(count); 🧠 What this taught me: • How nested loops actually work in real scenarios • Breaking a problem into smaller steps • Writing simple, readable logic ⚡ Next step: I’ll try optimizing this (maybe using includes() or a better approach) If you have a cleaner or more efficient solution, I’d love to see it. #JavaScript #ProblemSolving #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
Got a minute for some JavaScript? 🍵 What does this code output? Answers 🔍 >>> - ReferenceError: message is not defined Why? Because let lives only inside the block where it’s created. In this code, message is created inside the *if {}* and *else {}* blocks. When JavaScript reaches *console.log(message)*, it is already outside those blocks, so the variable no longer exists. #javascript #webdevelopment
To view or add a comment, sign in
-
-
Day 12 #100DaysOfCode 💻 Today I learned about Synchronous vs Asynchronous JavaScript, especially how setTimeout() and setInterval() work. JavaScript runs code synchronously by default (line by line). But functions like "setTimeout()" run asynchronously, meaning they execute later without blocking the main thread. Example: console.log("1"); setTimeout(() => { console.log("2"); }, 0); console.log("3"); Output: 1 3 2 Even with "0ms", "setTimeout" goes to the callback queue, so the synchronous code runs first. Understanding this concept helped me see how JavaScript handles non-blocking tasks. #JavaScript #AsyncJavaScript #WebDevelopment #CodingJourney #Akbiplob
To view or add a comment, sign in
-
Tip Calculator The game is simple to fetch the data from the HTML, make calculations and then update it via Javascript. The question is how, let's see more in the video. #learninginpublic #JavaScript #Codinglife #learningvideoediting
To view or add a comment, sign in
-
💡 JavaScript Trick Question: 3 + 2 + "7" In JavaScript, the answer is: 👉 "57" 🔍 Why? 🔹 JavaScript follows left-to-right evaluation and uses type coercion. ⚡ Key Insight : 🔹Once a string enters the expression, everything after that becomes a string operation. "In JavaScript, the moment a string joins the party, numbers stop adding and start concatenating." #JavaScript #WebDevelopment #CodingInterview #Frontend #JSConcepts
To view or add a comment, sign in
-
-
Day 14/21 : JavaScript DOM (Document Object Model) As part of my 21-Day Full Stack Revision Challenge, today I revised the DOM, which allows JavaScript to interact with and modify web pages. The DOM represents the webpage as a structured tree, making it possible to access and update elements dynamically. > Topics I Covered What is DOM – A representation of the HTML document Selecting Elements – Accessing elements using JavaScript Manipulating Content – Changing text, styles, and attributes Event Handling – Responding to user actions like clicks and inputs > Why It Matters DOM manipulation helps in creating interactive and dynamic web applications instead of static pages. Day 14 completed #FullStackDeveloper #JavaScript #DOM #WebDevelopment #LearningInPublic #21DaysChallenge #CodingJourney
To view or add a comment, sign in
-
If strings in JavaScript are primitives, how can we call methods like .split()? "hello".split("") At first this looks strange, because primitives are not objects. The reason it works is because JavaScript does something behind the scenes called auto-boxing. When you call a method on a string, JavaScript temporarily wraps the primitive into a String object, runs the method, and then removes the object. That’s why primitives like strings can still use methods. And this also explains this behavior "hello" === new String("hello") // false Because one is a primitive and the other is an object. #javascript
To view or add a comment, sign in
-
Got a minute for some JavaScript? 🍒 What does this code output? Answers 🔍 >>> - "Tom says meow" - TypeError: c.createKitten is not a function - "Kitty says meow" Why the TypeError? *createKitten* is a static method - it lives on the *Cat* constructor, not on instances. *c* is an instance, so it cannot access static methods. Only *Cat.createKitten()* works. #javascript #webdevelopment
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