🚀 Day 18/30 – JavaScript Challenge Solved: 2627. Debounce 💡 Today’s concept: Debouncing Function A debounced function delays execution and cancels previous calls if triggered again within a specific time. 👉 Key Idea: Use setTimeout Clear previous timer using clearTimeout Execute only the last function call after delay ⚙️ Approach: ✔ Maintain a timer variable ✔ On every call → clear previous timer ✔ Set a new timer to execute function after t ms. #JavaScript #LeetCode #CodingChallenge #WebDevelopment #Frontend #30DaysOfCode
JavaScript Debounce Function with setTimeout
More Relevant Posts
-
🧠 Day 10 of 21days challenge JavaScript call, apply, bind 🔥 They allow you to control what “this” refers to in a function. You can borrow functions and use them with different objects. For easy understanding :- call → pass arguments one by one apply → pass arguments as array bind → returns new function 👉 That’s how we control “this” in JavaScript This changed how I understand functions 🚀 #JavaScript #CallApplyBind #Frontend
To view or add a comment, sign in
-
-
🧠 Day 18 of 21days challenge JavaScript WeakMap ⚡ WeakMap is a collection where keys must be objects. It helps in memory management because keys are weakly referenced. For easy understanding :- WeakMap = object keys only Garbage collected if no other references Useful to store private data 👉 That’s how memory leaks can be prevented This changed how I manage objects efficiently 🚀 #JavaScript #WeakMap #InterviewPrep #Frontend
To view or add a comment, sign in
-
-
JavaScript basics that still matter: let vs var vs const var: • Function scoped • Can be redeclared let: • Block scoped • Can be updated const: • Block scoped • Cannot be reassigned Small concepts, big impact on clean code. Which one do you use the most? #JavaScript #CodingTips #Frontend
To view or add a comment, sign in
-
🚀 💡 JavaScript Tricky Question Explanation const arr = [4, 10, 2, 8]; const result = arr.find(num => num > 5) + arr.findIndex(num => num > 5); console.log(result); 👉 Output: 11 👉 Explanation: * find() returns the first value > 5 → `10` * findIndex() returns its index → `1` * Final result → `10 + 1 = 11` ⚡ Both stop at the **first match** #JavaScript #WebDevelopment #Frontend #CodingInterview #JSConcepts
To view or add a comment, sign in
-
A Complete Reference for JavaScript Dates JavaScript’s Date object is one of those things you think you know until you’re debugging a timezone issue at 4 PM on a Friday. I put together this quick cheat sheet to cover the essentials, from basic instantiation to local formatting. What’s your go-to library for dates? Are you team native Date, or do you still reach for Day.js or date-fns? #JavaScript #WebDevelopment #Frontend #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
-
🧠 Day 15 of 21days challenge Memoization in JavaScript ⚡ Why compute the same result again? Memoization stores the result of a function and returns the cached result when called with same input. For easy understanding :- Memoization = caching results Same input → no recomputation Improves performance 👉 That’s how expensive calculations are optimized This changed how I write efficient code 🚀 #JavaScript #Memoization #InterviewPrep #Frontend
To view or add a comment, sign in
-
-
setTimeout does nothing inside the JavaScript engine. It's a label. A facade. When you call it, JS hands the work off to a browser feature - the actual timer lives outside JavaScript entirely. The browser runs it independently while JS continues on to the next line. All the features we think of as "JavaScript" - timers, network requests, DOM interactions - are actually browser APIs. JS just has labels that trigger them. This is how JS avoids blocking. It doesn't wait. It delegates. The result comes back later, through a controlled channel called the callback queue. Next: the event loop - the single mechanism that controls when deferred code is allowed back into JavaScript. #JavaScript #WebDevelopment #Programming #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 19/30 – JavaScript Challenge Solved: 2721. Execute Asynchronous Functions in Parallel 💡 Today’s concept: Promise.all (Parallel Execution) We were given multiple async functions and needed to execute them in parallel, not one by one. 👉 Key Idea: Start all async functions at once Track results in order Resolve only when all are completed Reject immediately if any fails ⚙️ Approach: ✔ Create a result array ✔ Maintain a counter ✔ Call all functions simultaneously ✔ Store results by index ✔ Resolve when count matches length #JavaScript #AsyncProgramming #Promises #LeetCode #WebDevelopment #Frontend
To view or add a comment, sign in
-
-
Hoisting is a behavior in JavaScript where variable and function declarations are conceptually moved to the top of their containing scope (either the global script or a specific function) during the compilation phase, before the code is actually executed. It is important to understand that your code isn't physically moved anywhere. Instead, the JavaScript engine allocates memory for variable and function declarations before it executes the code line-by-line. #javascript #hoisting #frontend #scripting
To view or add a comment, sign in
-
-
Have you ever hit the “why is my input resetting on every render?” bug? ➤ Defining a component function inside another component creates a new function on every render 🔄🧠 ➤ React can treat it like a different component type 🎭❓ ➤ Result: inputs/state can reset repeatedly 🔁⚠️ ➤ Fix: define components at the top level (outside the parent component) 🔝✅ #React #JavaScript #Frontend #Debugging #BestPractices
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