#4 Currying in JavaScript: When it actually pays off Currying looks weird at first, but it solves a very practical problem: reuse. Currying is one of those JavaScript patterns that feels unusual at first, but it can make your code much more flexible. Instead of passing all arguments at once, you pass them one by one: f(a)(b)(c). That makes it easier to reuse functions when some values stay the same and others change often. Here’s the link to the post: https://lnkd.in/dkhKsRYa #javascript #react #node #interview
Mariusz Najwer’s Post
More Relevant Posts
-
One of the most common JavaScript interview questions: "Why does setTimeout with 0ms delay not run immediately?" Most developers cannot answer this correctly. Here is the full explanation: JavaScript is single-threaded. It can only do one thing at a time. The Event Loop is how it manages everything else. The execution order is always the same: 1 — Synchronous code runs first All regular code on the Call Stack executes immediately. 2 — Microtasks run second Promises, async/await — these run before anything else once the Call Stack is empty. 3 — Macrotasks run last setTimeout, setInterval, DOM events — these wait until ALL microtasks are done. This is why setTimeout with 0ms still runs after a Promise. The Promise is a microtask. setTimeout is a macrotask. Microtasks always win. Understanding this prevents real bugs in production — async state updates, race conditions, unexpected render order. Save this post for your next async debugging session. Have you ever been confused by JavaScript async order? Drop a comment below. #JavaScript #WebDevelopment #Frontend #SoftwareEngineering #AsyncJavaScript
To view or add a comment, sign in
-
-
Flattening arrays in JavaScript doesn’t have to be complicated 👇 Instead of writing long logic, just remember this: 🔹 Use flat(Infinity) 🔹 It converts nested arrays into a single-level array in one line. For interviews, knowing the recursive approach gives you an extra edge. #JavaScript #WebDevelopment #CodingTips #Frontend #LearnToCode
To view or add a comment, sign in
-
-
🚀 Day 3 — Mastering JavaScript Operators & Type Conversion Continuing the journey of strengthening core JavaScript fundamentals, today was all about understanding how operations and expressions actually work behind the scenes. 🔹 Covered topics: - Operators in JavaScript (in detail): • Arithmetic • Assignment • Comparison • Logical • String • Ternary - Operator Precedence (which operation runs first) - Associativity (direction of execution) - Type Coercion (Implicit & Explicit) — in depth - Interview-focused questions with real examples 💡 Key Learning: JavaScript doesn’t just execute code — it follows specific rules like precedence, associativity, and type conversion. Sometimes the output is not what we expect… and that’s where real understanding matters. 👉 Small concepts like: - Why ""5" + 2" gives ""52"" - How "==" behaves differently from "===" - How operator precedence changes results These are exactly the kind of tricky questions asked in interviews. This phase is helping me move from just writing code → to actually understanding how JavaScript thinks ⚡ 📌 Day 3 of consistent preparation — getting stronger every day 🔥 #JavaScript #WebDevelopment #FullStackDeveloper #CodingJourney #MERNStack #InterviewPreparation #Frontend #Backend #LearnInPublic #Developers #Linkedin #Connections
To view or add a comment, sign in
-
🚀 Day 14/30 of My JavaScript Challenge Solved LeetCode 2715 - Timeout Cancellation ✅ 💡 What I Learned Today: ⏳ How setTimeout() delays function execution ❌ How clearTimeout() cancels a scheduled task 🔁 Returning functions from functions (Higher-Order Functions) 🧠 Managing async behavior in JavaScript 📌 Approach: Created a cancellable function that schedules execution using setTimeout(). Then returned a cancelFn which uses clearTimeout() to stop execution before the delay ends. ✨ Key Insight: JavaScript timers can be controlled dynamically, which is useful in search debouncing, API calls, and UI interactions. #JavaScript #LeetCode #30DaysChallenge #WebDevelopment #AsyncJavaScript #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🧠 Day 12 of 21days challenge JavaScript "this" keyword 🤯 const user1 = { name: "Shubham" } const user2 = { name: "Rahul" } Same function. Different outputs. Why? Because "this" is not defined where the function is written. It is decided when the function is called. For easy understanding :- this = caller object Determined at runtime Depends on how function is invoked 👉 That’s why the same function behaves differently This changed how I understand function execution 🚀 #JavaScript #ThisKeyword #InterviewPrep #Frontend
To view or add a comment, sign in
-
-
𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗘𝘃𝗲𝗻𝘁𝗟𝗼𝗼𝗽 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱 (𝗔 𝗠𝘂𝘀𝘁‐𝗞𝗻𝗼𝘄 𝗖𝗼𝗻𝗰𝗲𝗽𝘁) Understanding the JavaScript Event Loop is a game changer for writing efficient and predictable asynchronous code. Many developers use setTimeout and Promises every day — but far fewer truly understand how JavaScript executes async tasks behind the scenes. Let’s break it down 👇 𝗛𝗼𝘄 𝘁𝗵𝗲 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 𝗪𝗼𝗿𝗸𝘀 • JavaScript runs on a single thread • Synchronous code executes first via the Call Stack • Then Microtasks run (like Promises) • Next, one Macrotask executes (timers, events) • This cycle continues repeatedly 𝗘𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻 𝗣𝗿𝗶𝗼𝗿𝗶𝘁𝘆 ➡️ Synchronous ➡️ Microtasks ➡️ Macrotasks 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗰𝗼𝗻𝗰𝗲𝗽𝘁 𝗺𝗮𝘁𝘁𝗲𝗿𝘀 ✅ Debug async issues with confidence ✅ Avoid unexpected execution order ✅ Build more predictable React applications ✅ Frequently tested in frontend interviews #JavaScript #EventLoop #FrontendDevelopment #ReactJS #WebDevelopment #InterviewPrep #AsyncJavaScript #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 9/30 Functions, Parameters, and Return Values in JavaScript Functions in JavaScript are reusable blocks of code designed to perform specific tasks. They help improve organization, reduce repetition, and make programs easier to maintain. A function can receive Parameters, which act like placeholders for values that are passed in when the function is called. These parameters allow the function to work with dynamic input. After processing the input, a function can provide an output using the return statement. The returned value can then be stored, displayed, or used in further calculations. Together, functions, parameters, and return values make JavaScript logic flexible, reusable, and efficient. #M4ACELearningChallenge #QualityAssurance #AutomationTesting #JavaScript #LearningInPublic
To view or add a comment, sign in
-
🧠 Day 11 of 21days challenge Shallow vs Deep Copy in JavaScript ⚠️ const copy = { ...obj }; Looks like a copy… but not always safe. Shallow copy duplicates only top-level properties. Deep copy creates a completely independent object. For easy understanding :- Shallow copy = shared nested reference Deep copy = fully independent copy Shallow changes affect original 👉 That’s why bugs happen in state updates This changed how I handle object mutations 🚀 #JavaScript #Frontend #InterviewPrep
To view or add a comment, sign in
-
-
One of the interesting questions asked in my interview was: ❓ “What are Microtasks and Macrotasks in JavaScript?” 💠 Understanding the Concept 🔹 JavaScript uses an event loop to handle asynchronous operations. 📌 Tasks are mainly divided into: 👉 Micro tasks : 🔹 High priority tasks 🔹 Executed immediately after the current synchronous code 🔹 Processed before macrotasks ✅ Examples: 🔹 Promise.then() 🔹 catch, finally 🔹 queueMicrotask() 👉 Macro tasks : 🔹 Lower priority compared to microtasks 🔸 Executed after microtasks queue is empty ✅ Examples: 🔹 setTimeout() 🔹 setInterval() 🔹 setImmediate() (Node.js) 🔄 Execution Order 🔹 Run synchronous code 🔹 Execute all microtasks 🔹 Execute one macrotask 🔹 Repeat This question tests understanding of Event loop, Asynchronous behavior and Execution order in JavaScript #JavaScript #EventLoop #AsyncProgramming #InterviewPrep #WebDevelopment #Learning #frontend #interviewExxperiance #interview
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