⚙️ process.nextTick vs setImmediate vs setTimeout vs setInterval — Node.js Interview🔥 If you're preparing for backend interviews, understanding how Node.js handles async execution is a big differentiator. These functions are often confusing—but super important 👇 🔹 process.nextTick() → Runs immediately (microtask queue) * Executes right after the current operation * Runs before the event loop continues * Highest priority 👉 Use when: You want something to run ASAP after current code 📌 Example: process.nextTick(() => console.log("nextTick")); console.log("sync"); 🔹 setImmediate() → Runs in next event loop cycle * Executes in the check phase * Runs after I/O operations * Lower priority than nextTick 👉 Use when: You want to defer execution 📌 Example: setImmediate(() => console.log("setImmediate")); 🔹 setTimeout() → Runs after delay (minimum time) * Executes after a specified delay (not exact timing) * Runs in the timers phase * `0ms` doesn’t mean immediate execution 👉 Use when: Delay execution 📌 Example: setTimeout(() => console.log("timeout"), 0); 🔹 setInterval() → Runs repeatedly * Executes a function at fixed intervals * Continues until cleared 👉 Use when: Repeating tasks (polling, timers) 📌 Example: setInterval(() => console.log("running..."), 1000); 🔹 Key Differences (Quick View) process.nextTick(): * Executes immediately after current operation * Microtask queue * Highest priority setImmediate(): * Executes in next event loop cycle * Check phase setTimeout(): * Executes after delay * Timers phase setInterval(): * Executes repeatedly after fixed delay 🔹 Interview Tip If asked: 👉 Difference between nextTick, setImmediate, and setTimeout? 💡 Answer smartly: * nextTick → before event loop continues * setTimeout(0) → timers phase * setImmediate → check phase ⚠️ Pro Tip: Overusing `process.nextTick()` can block the event loop. Use it wisely. Master the event loop = Master Node.js 🚀 #NodeJS #JavaScript #BackendDevelopment #EventLoop #CodingInterview #SoftwareEngineer #LearnToCode
Node.js Async Execution: process.nextTick, setImmediate, setTimeout, setInterval
More Relevant Posts
-
🚀 Interview Experience – Frontend (React/JavaScript) | Persistent Systems Recently had an interesting interview experience with Persistent Systems and wanted to share some of the questions/topics that were discussed. It was a great mix of practical coding, core JavaScript concepts, and frontend fundamentals. 🔹 Coding / Problem-Solving 1. A parent div with 3 child divs. You need to place first at bottom-left and second at bottom-middle and third one at bottom-right. 🔹 JS output-based questions: 🌞 (function () { try { throw new Error(); } catch (x) { var x = 1, y = 2; console.log(x); } console.log(x); console.log(y); })(); 🌞 console.log(0 || 1); //1 console.log(1 || 2); //1 console.log(0 && 1); //0 console.log(1 && 2); // 2 🌞 (function(){ var a = b = 3; })(); console.log(a); console.log(b); 🌞 Create a React component that allows a user to select a file and simulate an upload process. When the user clicks the upload button, display a progress bar that gradually fills from 0% to 100% and show the upload percentage. The progress bar should update dynamically using React state. 🔹 Core JavaScript Concepts 1. Currying (currying vs normal functions) 2. call, apply, bind – when to use 3. Event loop 4. Promises: Promise.all, Promise.allSettled, Promise.race 5. Debouncing vs Throttling 6. Sync vs Deferred execution 7. Object & Array Destructuring 8. Difference between for...of and for...in . 🔹 React Topics 1. Hooks 2. useState – async or sync? How it works internally 3. Error Boundaries 4. Redux / Redux Toolkit flow 🔹 HTML & CSS Fundamentals 1. Box Model 2. CSS Specificity 3. Pseudo-classes and Pseudo-elements 4. Accessibility. Responsive Design techniques 🔹 Testing - Writing test cases (basic understanding expected) 💡 Overall, the interview focused more on fundamentals + real-world implementation rather than just theory. Would love to hear if you've come across similar questions or patterns! 👇 #PersistentSystems #Frontend #JavaScript #ReactJS #WebDevelopment #InterviewExperience #CodingInterview #Learning #CareerGrowth
To view or add a comment, sign in
-
⚡ Promise vs Async/Await — Explained with Code (Interview Ready) If you're preparing for JavaScript / React interviews, this is a must-know concept 👇 --- 🔹 What is a Promise? A Promise represents a future value (pending → resolved → rejected) --- 💻 Promise Example function fetchData() { return new Promise((resolve, reject) => { setTimeout(() => { resolve("Data received"); }, 1000); }); } fetchData() .then(res => console.log(res)) .catch(err => console.log(err)); --- 🔹 What is Async/Await? A cleaner way to work with Promises using synchronous-looking code --- 💻 Async/Await Example async function getData() { try { const res = await fetchData(); console.log(res); } catch (err) { console.log(err); } } getData(); --- 🔥 Key Differences 👉 Syntax - Promise → ".then().catch()" - Async/Await → "try...catch" 👉 Readability - Promise → can become nested (callback chain) - Async/Await → clean & easy to read 👉 Error Handling - Promise → ".catch()" - Async/Await → "try/catch" 👉 Execution - Both are asynchronous (no difference in performance) --- 🌍 Real-world Scenario 👉 API calls in React - Promise → chaining multiple ".then()" - Async/Await → clean API logic inside "useEffect" --- 🎯 Interview One-liner “Async/Await is syntactic sugar over Promises that makes asynchronous code easier to read and maintain.” --- 🚀 Use Async/Await for better readability, but understand Promises deeply! #JavaScript #ReactJS #Frontend #AsyncAwait #Promises #InterviewPrep
To view or add a comment, sign in
-
Want to Ace 👉 Web4you hashtag #JavaScript #Interviews? Master the Event Loop and Its Core Components! 𝟭. 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Call Stack is where JavaScript keeps track of function calls. It is a stack structure that handles synchronous code execution. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When a function is invoked, it’s pushed onto the stack. 2. Once it finishes, it’s popped off. 3. If an error occurs during execution, it’s thrown from the stack. 𝟮. 𝗘𝘃𝗲𝗻𝘁 𝗤𝘂𝗲𝘂𝗲 (𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲) - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Queue (also known as the callback queue) stores events that are to be processed asynchronously, like events triggered by a setTimeout or DOM events. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When the Call Stack is empty, the Event Loop checks the Event Queue. 2. It then pushes the next task onto the stack for execution. 𝟯. 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸 𝗤𝘂𝗲𝘂𝗲 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Microtask Queue holds tasks that need to be executed after the currently executing script, but before any events in the event queue. Microtasks include promise callbacks and other tasks like MutationObserver. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? Once the call stack is empty and before the event queue is processed, the event loop picks up and processes tasks in the microtask queue. This ensures that promises are resolved before other events are processed. 𝟰. 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Loop is the mechanism that allows JavaScript to perform non-blocking operations by managing the order in which tasks are executed from the call stack, event queue, and microtask queue. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The event loop constantly checks the call stack. If the call stack is empty, it checks the microtask queue and processes any pending microtasks. After all microtasks are processed, the event loop picks events from the event queue for execution. 𝗞𝗲𝘆 𝗣𝗼𝗶𝗻𝘁: Microtasks are always executed before the event queue. This is why Promise.then() is processed before setTimeout(). 𝟱. 𝗦𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁 𝗮𝗻𝗱 𝗦𝗲𝘁𝗜𝗻𝘁𝗲𝗿𝘃𝗮𝗹 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? setTimeout() and setInterval() are used to schedule code execution after a specified time, but they are added to the event queue and are processed after all synchronous code and microtasks. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The setTimeout() and setInterval() tasks are executed after the current script is finished executing, which is why you may see asynchronous code run after synchronous code (even if it's scheduled for immediate execution). Follow Arun Dubey for more related content! #javascript #eventloop #frontend #reactjs #questions
To view or add a comment, sign in
-
-
Angular Interview Questions (4+ Years Experience) - L1 Round (Persistent) Recently one of my connections shared their interview experience (4+ years exp). Sharing exactly how he shared it 👇 1) git commands for creating branch 2) for switching branch 3) what is cherrypick 4) Best way to handle errors globally in project 5) asked to write interceptor code for attaching token to every request and handling errors 6) how to optimize performance in angular application 7) what steps to be followed bottleneck in slow application 8) what is the ideal time for an api to give response 9) what is cdn, for what purpose it is used 10) what is vanilla js 11) what are promises, promise.all, race, allsettled 12) best practices to follow for performance in angular app 13) event loop 14) what is async/await, what is diff bw promises and async/await 15) Generator fn output based questions 16) prototypal inheritance based questions 17) variance in ts 18) diff bw any and unknown 19) as and generics diff 20) shadowing in js 21) parseInt('08',10), parseInt('08') Coding Snippets generator fn output function add(){ yield* 1 yield [2,3] return 4 } console.log(add().next(), add().next(), add().next(), add().next()) diff bw slice and splice function A() {} A.prototype.p = 1; const x = new A(); x.p = 2; delete x.p; console.log(x.p); delete A.prototype.p; console.log(x.p); If you’re preparing for 3–5 years experience roles… this is the level of depth expected now. 🔁 Repost this so your connections also see it — helps more people + brings the right audience to your profile. 👉 Follow me Chetan Jogi for more real interview questions & dev content #angularInterview #angularJobs #angularInterviewQuestions #javascriptInterview #javascriptInterviewQuestions #angularDeveloper #interviewPreparation
To view or add a comment, sign in
-
5 Advanced Next.js 15 Interview Questions Headline: Is your Next.js expertise ready for the Server-First Era? ⚛️🏢 The bar for "Senior Frontend" has moved. In 2026, interviewers aren't just asking about basic routing; they are testing your ability to orchestrate React Server Components (RSC) and Agentic Data Fetching. If you are interviewing for a Lead role this month, you need to master these 5 questions: 1. The "use client" Boundaries Question: In the App Router, why is the goal to "push 'use client' as far down the component tree as possible"? The Answer: To maximize the benefits of Server Components—reducing client-side JavaScript bundles and keeping sensitive logic (like API keys or DB queries) entirely on the server. 2. Layouts vs. Templates Persistence Question: What is the critical difference between layout.js and template.js during route navigation? The Answer: Layouts persist state and do NOT re-render on navigation, while Templates create a new instance on every navigation, resetting state—useful for enter/exit animations. 3. Incremental Static Regeneration (ISR) vs. Streaming Question: When would you choose Streaming with Suspense over ISR for a data-heavy dashboard? The Answer: ISR is best for content that updates periodically (like product pages); Streaming is superior for real-time, user-specific data where you want to show the page shell instantly while loading slow content in the background. 4. Server Actions & Form State Question: How do Server Actions change the way we handle "Optimistic UI" updates compared to traditional API routes? The Answer: Server Actions allow direct server-side data mutations from Client Components; when combined with useOptimistic, you can update the UI instantly before the server even confirms the action. 5. Middleware & RBAC Question: Why is it safer to implement Role-Based Access Control (RBAC) in Middleware rather than exclusively inside Server Components? The Answer: Middleware intercepts the request before the rendering process begins, preventing unauthorized users from even triggering server-side data fetching or hitting protected route segments. The Bottom Line: In 2026, your value is no longer just "writing code," but architecting secure, high-performance systems that leverage the full server-side potential of Next.js. Which of these features has been your biggest "gotcha" this year? 👇 #NextJS #ReactJS #WebDevelopment #SoftwareArchitecture #TypeScript #FullStack #BuildInPublic
To view or add a comment, sign in
-
-
Want to Ace 👉 Web4you #JavaScript #Interviews? Master the Event Loop and Its Core Components! 𝟭. 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Call Stack is where JavaScript keeps track of function calls. It is a stack structure that handles synchronous code execution. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When a function is invoked, it’s pushed onto the stack. 2. Once it finishes, it’s popped off. 3. If an error occurs during execution, it’s thrown from the stack. 𝟮. 𝗘𝘃𝗲𝗻𝘁 𝗤𝘂𝗲𝘂𝗲 (𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲) - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Queue (also known as the callback queue) stores events that are to be processed asynchronously, like events triggered by a setTimeout or DOM events. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When the Call Stack is empty, the Event Loop checks the Event Queue. 2. It then pushes the next task onto the stack for execution. 𝟯. 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸 𝗤𝘂𝗲𝘂𝗲 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Microtask Queue holds tasks that need to be executed after the currently executing script, but before any events in the event queue. Microtasks include promise callbacks and other tasks like MutationObserver. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? Once the call stack is empty and before the event queue is processed, the event loop picks up and processes tasks in the microtask queue. This ensures that promises are resolved before other events are processed. 𝟰. 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Loop is the mechanism that allows JavaScript to perform non-blocking operations by managing the order in which tasks are executed from the call stack, event queue, and microtask queue. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The event loop constantly checks the call stack. If the call stack is empty, it checks the microtask queue and processes any pending microtasks. After all microtasks are processed, the event loop picks events from the event queue for execution. 𝗞𝗲𝘆 𝗣𝗼𝗶𝗻𝘁: Microtasks are always executed before the event queue. This is why Promise.then() is processed before setTimeout(). 𝟱. 𝗦𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁 𝗮𝗻𝗱 𝗦𝗲𝘁𝗜𝗻𝘁𝗲𝗿𝘃𝗮𝗹 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? setTimeout() and setInterval() are used to schedule code execution after a specified time, but they are added to the event queue and are processed after all synchronous code and microtasks. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The setTimeout() and setInterval() tasks are executed after the current script is finished executing, which is why you may see asynchronous code run after synchronous code (even if it's scheduled for immediate execution). Follow Arun Dubey for more related content! #javascript #eventloop #frontend #reactjs #questions
To view or add a comment, sign in
-
-
Want to Ace 👉 Web4you #JavaScript #Interviews? Master the Event Loop and Its Core Components! 𝟭. 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Call Stack is where JavaScript keeps track of function calls. It is a stack structure that handles synchronous code execution. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When a function is invoked, it’s pushed onto the stack. 2. Once it finishes, it’s popped off. 3. If an error occurs during execution, it’s thrown from the stack. 𝟮. 𝗘𝘃𝗲𝗻𝘁 𝗤𝘂𝗲𝘂𝗲 (𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲) - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Queue (also known as the callback queue) stores events that are to be processed asynchronously, like events triggered by a setTimeout or DOM events. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When the Call Stack is empty, the Event Loop checks the Event Queue. 2. It then pushes the next task onto the stack for execution. 𝟯. 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸 𝗤𝘂𝗲𝘂𝗲 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Microtask Queue holds tasks that need to be executed after the currently executing script, but before any events in the event queue. Microtasks include promise callbacks and other tasks like MutationObserver. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? Once the call stack is empty and before the event queue is processed, the event loop picks up and processes tasks in the microtask queue. This ensures that promises are resolved before other events are processed. 𝟰. 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Loop is the mechanism that allows JavaScript to perform non-blocking operations by managing the order in which tasks are executed from the call stack, event queue, and microtask queue. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The event loop constantly checks the call stack. If the call stack is empty, it checks the microtask queue and processes any pending microtasks. After all microtasks are processed, the event loop picks events from the event queue for execution. 𝗞𝗲𝘆 𝗣𝗼𝗶𝗻𝘁: Microtasks are always executed before the event queue. This is why Promise.then() is processed before setTimeout(). 𝟱. 𝗦𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁 𝗮𝗻𝗱 𝗦𝗲𝘁𝗜𝗻𝘁𝗲𝗿𝘃𝗮𝗹 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? setTimeout() and setInterval() are used to schedule code execution after a specified time, but they are added to the event queue and are processed after all synchronous code and microtasks. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The setTimeout() and setInterval() tasks are executed after the current script is finished executing, which is why you may see asynchronous code run after synchronous code (even if it's scheduled for immediate execution). Follow Arun Dubey for more related content! #javascript #eventloop #frontend #reactjs #questions
To view or add a comment, sign in
-
-
Want to Ace 👉 Web4you #JavaScript #Interviews? Master the Event Loop and Its Core Components! 𝟭. 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Call Stack is where JavaScript keeps track of function calls. It is a stack structure that handles synchronous code execution. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When a function is invoked, it’s pushed onto the stack. 2. Once it finishes, it’s popped off. 3. If an error occurs during execution, it’s thrown from the stack. 𝟮. 𝗘𝘃𝗲𝗻𝘁 𝗤𝘂𝗲𝘂𝗲 (𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲) - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Queue (also known as the callback queue) stores events that are to be processed asynchronously, like events triggered by a setTimeout or DOM events. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? 1. When the Call Stack is empty, the Event Loop checks the Event Queue. 2. It then pushes the next task onto the stack for execution. 𝟯. 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸 𝗤𝘂𝗲𝘂𝗲 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Microtask Queue holds tasks that need to be executed after the currently executing script, but before any events in the event queue. Microtasks include promise callbacks and other tasks like MutationObserver. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? Once the call stack is empty and before the event queue is processed, the event loop picks up and processes tasks in the microtask queue. This ensures that promises are resolved before other events are processed. 𝟰. 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? The Event Loop is the mechanism that allows JavaScript to perform non-blocking operations by managing the order in which tasks are executed from the call stack, event queue, and microtask queue. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The event loop constantly checks the call stack. If the call stack is empty, it checks the microtask queue and processes any pending microtasks. After all microtasks are processed, the event loop picks events from the event queue for execution. 𝗞𝗲𝘆 𝗣𝗼𝗶𝗻𝘁: Microtasks are always executed before the event queue. This is why Promise.then() is processed before setTimeout(). 𝟱. 𝗦𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁 𝗮𝗻𝗱 𝗦𝗲𝘁𝗜𝗻𝘁𝗲𝗿𝘃𝗮𝗹 - 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗶𝘁? setTimeout() and setInterval() are used to schedule code execution after a specified time, but they are added to the event queue and are processed after all synchronous code and microtasks. - 𝗛𝗼𝘄 𝗱𝗼𝗲𝘀 𝗶𝘁 𝘄𝗼𝗿𝗸? The setTimeout() and setInterval() tasks are executed after the current script is finished executing, which is why you may see asynchronous code run after synchronous code (even if it's scheduled for immediate execution). Follow Arun Dubey for more related content! #javascript #eventloop #frontend #reactjs #questions
To view or add a comment, sign in
-
-
💡 **Daily React/JavaScript Interview Tip**Promises aren’t just about `.then()`—they’re about **handling multiple async operations efficiently**.👉 Weak answer:“Promise.all runs multiple promises.”✅ Stronger answer:“I use different Promise methods depending on the scenario—like `Promise.all` for parallel execution when all must succeed, and `Promise.allSettled` when I need results regardless of failures.”⚡ Quick breakdown:* `Promise.all` → fails fast if one promise rejects* `Promise.allSettled` → waits for all, returns success + failure results* `Promise.resolve` → wraps a value into a resolved promise* `Promise.reject` → creates an immediately rejected promise🧠 Example:```js id="1j9k2x"const p1 = Promise.resolve(1);const p2 = Promise.reject('Error');const p3 = Promise.resolve(3);Promise.allSettled([p1, p2, p3]).then(console.log);```👉 Output:[{ status: 'fulfilled', value: 1 },{ status: 'rejected', reason: 'Error' },{ status: 'fulfilled', value: 3 }]📌 Tip: Don’t just explain what each method does—explain **when and why you’d use it in real-world scenarios**.#JavaScript #Promises #AsyncJavaScript #WebDevelopment #TechInterviews
To view or add a comment, sign in
-
🚀 React JS Interview Coding Questions (For Mid–Senior Developers) If you're preparing for React interviews (3–10+ years experience), these coding questions are MUST practice 👇 🔥 1. Debounced Search Input Build a search bar that calls API only after user stops typing (use "useEffect + setTimeout" or custom hook). 🔥 2. Infinite Scroll Load more data when user reaches bottom (Intersection Observer API). 🔥 3. Custom useFetch Hook Create reusable hook with loading, error, and data handling. 🔥 4. Optimized Re-rendering Prevent unnecessary re-renders using "React.memo", "useMemo", "useCallback". 🔥 5. Form Handling + Validation Build form with controlled inputs + validation (email, password rules). 🔥 6. Implement Dark/Light Mode Toggle theme using Context API or Redux. 🔥 7. Role-Based Routing Admin/User protected routes using JWT + React Router. 🔥 8. Shopping Cart Logic Add/remove/update quantity + total price calculation. 🔥 9. File Upload with Preview Upload image and show preview before submit. 🔥 10. Build a Modal from Scratch Reusable modal with open/close, backdrop, and ESC key support. --- 💡 Bonus (Advanced Level): ✔ Implement Virtualized List (performance optimization) ✔ Build your own Redux-like state manager ✔ Micro-frontend integration in React ✔ Web Workers for heavy calculations --- 🎯 Pro Tip: In interviews, focus more on: - Clean code structure - Reusability (custom hooks/components) - Performance optimization - Edge cases handling --- 💬 Which question do you find most challenging? Let’s discuss in comments 👇 #ReactJS #FrontendDeveloper #JavaScript #CodingInterview #WebDevelopment #ReactInterview
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