💡 My Recent Interview Experience – JavaScript & Node.js Deep Dive Recently, I came across some really interesting event loop and async behavior questions during an interview. Thought of sharing them here — great for anyone preparing for frontend/backend roles 🚀 🔹 Question 1: Promise Behavior 1) const promise1 = new Promise((resolve, reject) => { console.log(1) resolve('resolve1') }) const promise2 = promise1.then((res) => { console.log(res) }) console.log('promise1:', promise1); console.log('promise2:', promise2); 👉 What will be the output? 2) console.log("start"); setTimeout(() => { console.log("timeout"); }, 0); Promise.resolve().then(() => { console.log("promise1"); }).then(() => { console.log("promise2"); }); process.nextTick(() => { console.log("nextTick"); }); console.log("end"); 👉 What will be the output? 🔹 Question 2: Event Loop Priority setTimeout(() => console.log("timeout1"), 0); setImmediate(() => console.log("immediate1")); Promise.resolve().then(() => console.log("promise")); process.nextTick(() => console.log("nextTick")); console.log("sync"); 👉 Predict the output order. 🔹 Question 3: Tricky Execution Order 😄 console.log("A"); setTimeout(() => { console.log("B"); Promise.resolve().then(() => { console.log("C"); }); process.nextTick(() => { console.log("D"); }); }, 0); setImmediate(() => { console.log("E"); }); Promise.resolve().then(() => { console.log("F"); }); process.nextTick(() => { console.log("G"); }); console.log("H"); 👉 What is the final output? 🔹 Question 4: Nested Microtasks & nextTick Promise.resolve().then(() => { console.log("p1"); process.nextTick(() => { console.log("nt1"); }); Promise.resolve().then(() => { console.log("p2"); }); }); process.nextTick(() => { console.log("nt2"); }); console.log("end"); 👉 Guess the output. 🔹 Question 5: I/O + setImmediate vs setTimeout const fs = require("fs"); fs.readFile(__filename, () => { console.log("readFile"); setTimeout(() => console.log("timeout"), 0); setImmediate(() => console.log("immediate")); }); console.log("start"); 👉 What will be the output? 🧠 These questions really test your understanding of: Event Loop phases Microtasks vs Macrotasks process.nextTick priority setImmediate vs setTimeout Promise chaining behavior 💬 Drop your answers in the comments—let's discuss! #javascript #nodejs #frontend #interviewpreparation #webdevelopment #softwareengineering #codinginterview
JavaScript Node.js Interview Questions: Event Loop and Async Behavior
More Relevant Posts
-
7 JavaScript interview questions that trip up even senior devs. I've seen all of these asked in real interviews. And I've seen experienced engineers get them wrong. Not because they're bad engineers — because JavaScript is weird. Save this for your next interview prep. 1. What's the output? console.log(typeof null); Most people say "null." The answer is "object." It's a 25-year-old bug in JS that was never fixed. Interviewers love this one. 2. What gets logged? for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } Not 0, 1, 2. It's 3, 3, 3. Because var is function-scoped and by the time the timeout runs, the loop is done. Fix? Use let instead of var. 3. What's the difference between == and ===? Everyone says "== does type coercion." But can you explain WHY [] == false is true while [] is truthy? That's where it gets tricky. The real answer involves the Abstract Equality Comparison Algorithm. 4. What's the output? console.log(0.1 + 0.2 === 0.3); It's false. Floating point precision. 0.1 + 0.2 is actually 0.30000000000000004. This catches everyone at least once. 5. What does this return? function foo() { return { name: "Sanket" } } It returns undefined. Not the object. JavaScript's automatic semicolon insertion adds a semicolon after return. The object is unreachable code. 6. What's the difference between null and undefined? undefined means a variable was declared but never assigned. null means you intentionally set it to "nothing." They're different types but == says they're equal. === says they're not. 7. What's the output? const arr = [1, 2, 3]; arr[10] = 11; console.log(arr.length); It's 11. Not 4. JavaScript creates "empty slots" for indices 3-9. The array has holes. The pattern I've noticed — the questions that trip people up aren't about frameworks or patterns. They're about understanding how JavaScript actually works under the hood. If you know the quirks, you'll stand out in any interview. Which JS question tripped YOU up the hardest? Drop it below — let's build a thread of tricky ones 👇 #JavaScript #InterviewPrep #WebDevelopment #Deel #SoftwareEngineering
To view or add a comment, sign in
-
💡 Senior-Level Interview Question: “Explain everything you know about JavaScript and React in 5–10 minutes.” This isn’t a question about coverage — it’s about depth, clarity, and system thinking. Here’s how I’d structure a senior-level answer 👇 --- 🧠 1. JavaScript — The Execution Model First I start with how JavaScript actually runs: - Single-threaded execution model - Call stack, heap memory, and execution context - Event loop, microtasks vs macrotasks Understanding this explains: 👉 Why async code behaves the way it does 👉 How promises and "async/await" are scheduled 👉 Why race conditions and UI blocking happen Then I move into core language mechanics: - Closures & lexical scope (foundation of hooks & state) - Prototypal inheritance vs classical patterns - "this" binding (call, apply, bind, arrow functions) - Immutability & reference vs value (critical for React rendering) --- ⚛️ 2. React — Architecture Over Syntax React is not just a library — it’s a rendering and state management model. I explain it in terms of: 👉 Declarative UI: UI = f(state) 👉 Component-driven architecture 👉 Unidirectional data flow Then I go deeper into how React actually works internally: - Virtual DOM & reconciliation (diffing algorithm) - Fiber architecture (incremental rendering, prioritization) - Concurrent rendering (interruptible work, scheduling) --- 🔁 3. Rendering & State Management (Critical Area) This is where most senior discussions happen: - What triggers a re-render? - How React batches updates - How state is preserved across renders Then hooks with behavioral understanding: - "useState" → async updates & batching - "useEffect" → lifecycle + side effect orchestration - "useMemo" / "useCallback" → referential stability & optimization - "useRef" → mutable values without re-render --- ⚡ 4. Performance & Optimization Mindset Senior engineers think in trade-offs: - Avoiding unnecessary re-renders - Memoization strategies - Code-splitting & lazy loading - Handling large lists (windowing/virtualization) Also: 👉 When NOT to optimize (very important signal of maturity) --- 🏗️ 5. Scalable Frontend Architecture I shift from concepts → systems: - Component design patterns (container/presentational, hooks-based abstraction) - State management choices (Context vs Redux vs server state tools) - Separation of concerns - API/data layer handling (caching, retries, error boundaries) --- 🧩 6. Real-World Engineering Thinking Finally, I connect everything to production: - Handling async flows & race conditions - Managing side effects cleanly - Writing testable and maintainable components - Debugging re-render issues --- At a senior level, this question is not about listing hooks or features. It’s about demonstrating: ✔️ Mental models ✔️ Trade-off awareness ✔️ Ability to connect JavaScript fundamentals to React behavior How you can cover in 10min? #ReactJS #JavaScript #SeniorDeveloper #FrontendArchitecture #SystemDesign #InterviewPreparation
To view or add a comment, sign in
-
Senior JS Interviews aren't about 'hoisting' anymore. 🚀 In 2025/2026, senior frontend interviews have shifted. Interviewers at places like #Meta and #Stripe are testing your architectural prowess in modern ECMAScript. Do you know: 🔹 How to use ES2025 Proxies for deep reactivity? 🔹 Structural Sharing for efficient state updates? 🔹 The nuance of Macrotasks vs Microtasks in complex async flows? MockExperts have compiled the 10 Modern JavaScript Patterns you must know to prove your seniority. Check it out here: 🔗 https://lnkd.in/gFWUaaqE #JavaScript #FrontendEngineering #WebDevelopment #SeniorEngineer #React #CodingPatterns
To view or add a comment, sign in
-
🚀 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
-
https://lnkd.in/dAcv7KWH - Most Frontend Engineer interviews are broken because they focus on the wrong "basics." If you want to land a high-paying React.js role in this market, you need a strategy that goes beyond simple state updates. 🚀 I’ve spent the last month researching what top-tier companies actually ask in 2024 for this 5,000-word guide. The bar has shifted significantly from "can you make it work" to "can you make it scale and stay type-safe." 🧠 While writing Part 81, I noticed a huge gap in how candidates handle system design interview frontend questions. I remember my first big tech interview where I completely fumbled a question about complex state management. 🛠️ I was talking about old-school boilerplate while the interviewer wanted to hear about high-performance primitives like Zustand or TanStack Query. It was a wake-up call that my knowledge was lagging behind the modern baseline. 💡 This guide dives deep into TypeScript patterns and React 19 features that actually move the needle on your salary. We cover everything from optimizing your Vite build to writing robust end-to-end tests with Playwright. 🎯 Don't get left behind by using 2018 logic in a 2024 market. 🔥 Building at frontendengineers.com is my way of making sure you have the deep-dives needed to become a top 1% engineer. 📈 What's the most "unfair" or unexpected question you've ever been asked in a frontend interview? 💬 #FrontendEngineer #TypeScript #ReactJS #WebDevelopment #SoftwareEngineering #CodingInterview #SystemDesign #JavaScript #React19 #Zustand #TanStackQuery #Vite #Playwright #FrontendDevelopment #CareerGrowth #TechJobs #InterviewPrep #Programming #FullStack #SoftwareDeveloper #SalaryNegotiation #ReactDeveloper #RemoteJobs #ReactJSJobs #JSInterview #CSSInterview #HTMLInterview #BehavioralInterview #WebPerformance #StateManagement #CodeQuality #EngineeringManager #SeniorEngineer #TechInterview #ReactPatterns #FrontendEngineers #JobSearch #CareerAdvice #ComputerScience #CodingLife #DevCommunity #SoftwareArchitecture #WebDev #ReactContext #BootstrapReact #NextJS #WebDesign #OpenSource #DevOps #Testing #Automation #Productivity #TechTrends #ModernWeb #UIUX #DesignSystems #CleanCode #Scalability #TechnicalInterview #Hiring #Recruitment #FAANG #BigTech #StartupLife #LearnToCode #100DaysOfCode #CodeNewbie #TechStack #DeveloperExperience #FrontendGuide #CodingSkills #CareerSuccess #InterviewTips #JavaScriptTips #ReactTips
To view or add a comment, sign in
-
🧑💻 JavaScript Interview Prep: The Questions That Actually Matter Just wrapped up a series of JS interviews — here are the most frequently asked questions that separate "familiar" from "fluent." Save this for your next round! 👇 --- 🔹 Core Concepts 1. Hoisting – What gets hoisted? Variables (var vs let/const) vs function declarations. 2. Closures – Can you explain them and give a real-world use case? 3. Event Loop – How does async JavaScript work under the hood? (Call stack, Web APIs, task queue) 4. this binding – How does this behave in arrow functions vs regular functions? In event handlers? 5. Prototypes & Inheritance – What's the difference between classical and prototypal inheritance? 🔹 Async JavaScript 1. Promises – Implement Promise.all, Promise.race, or a simple sleep() function. 2. Async/Await – How would you handle errors? (try/catch vs .catch()) 3. Callbacks – What is callback hell and how do you avoid it? 🔹 Functional & Array Methods 1. map, filter, reduce – When to use each. Bonus: chain them. 2. Deep vs Shallow Copy – How to clone an object/array without mutating the original. 3. Immutability – Why does it matter in React/state management? 🔹 DOM & Browser APIs 1. Event Delegation – How does it work and why use it? 2. Debouncing vs Throttling – Implement a simple debounce function. 3. localStorage vs sessionStorage vs cookies – Key differences. 🔹 Tricky Ones 1. == vs === – When would == be acceptable? (Spoiler: rarely.) 2. null vs undefined vs undeclared – How to check for each. 3. Currying – Write a sum(1)(2)(3) function. --- 💡 Pro tip: Don't just memorize — understand the why. Interviewers are looking for problem-solving ability, not just syntax recall. What’s one JS question that always shows up in your interviews? Drop it in the comments 👇 #JavaScript #FrontendInterview #WebDevelopment #CodingInterview #JS
To view or add a comment, sign in
-
🚀 Out-of-the-Box JavaScript Interview Series – Think Beyond Basics! Tired of the same old JS interview questions like closures, promises, and hoisting? Let’s push the boundaries a bit and explore questions that actually test how you think 💡 Here are a few unconventional JavaScript interview challenges 👇 🔹 1. Why does this work? [] + [] === "" 👉 What’s happening behind the scenes with type coercion? 🔹 2. Can you break this comparison? true == '1' false == '0' 👉 Why does JS behave this way, and how would you avoid pitfalls in real apps? 🔹 3. Predict the output const obj = { a: 1, valueOf() { return 2; } }; console.log(obj + 1); 👉 Which method gets priority: valueOf or toString? 🔹 4. Infinite loop… or not? for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 0); } 👉 Why does this print 3 3 3? How would you fix it? 🔹 5. Can you make this true? a == 1 && a == 2 && a == 3 👉 Yes, it’s possible 😏 — but should you ever do it? 💬 These questions are not about memorization. They test: ✔️ Deep understanding of JavaScript internals ✔️ Edge-case thinking ✔️ Real-world debugging mindset 🔥 If you're preparing for senior/frontend roles, this is the level that makes you stand out. Follow for more in this Out-of-the-Box Interview Series 💯 #javascript #frontenddeveloper #webdevelopment #interviewquestions #codinginterview #js #softwareengineering #programming #developers #techinterview
To view or add a comment, sign in
-
Angular Interview Questions (6+ Years Experience) — L2 Round (Cognizant) One of my LinkedIn connections recently attended an L2 interview for a Senior Angular role (6+ years) and shared the questions she faced. Sharing this here so it helps others preparing for similar roles. 1) Explain memory allocation in JavaScript Sub Que: How to clear closure memory 2) List down ES6 features used in your project Sub Question : Where have you used destructuring and how often do you use Promises in Angular 3) What is your understanding of modules in JavaScript 4) Have you created any pure functions? Explain with use case 5) Have you created any recursive function? Explain it 6) we are working on project where use will login but even if user closed tab and again open we want to keep him still login ? how to achieve this 7) If the same dashboard data is available from multiple APIs, how would you call all APIs in JavaScript and use the response from whichever API returns first? 8) In our application, some users have very slow internet connections, so form submission APIs may take 6–8 seconds to respond. During this delay, users often click the submit button multiple times, causing duplicate records. How would you prevent this issue using JavaScript fundamentals? 9) You are working on a page that displays a table with search filters such as from date, to date, category, price range, and a search button. On search, an API call fetches the table data. Each row has an ‘Open’ button that navigates to a details page. When the user returns to the table page, the previously selected filters and the same table data should still be visible. How would you implement this using JavaScript fundamentals? 10) Difference between setValue and patchValue 11) List reusable components you have created 12) How you will create a reusable textbox whioch should support ngModel and FormControl also 13) What is tree shaking in Angular 14) RxJS operators — tap, race, map (asked with code explanation) 15) Logout button is in navbar but user activity is in dashboard — how will you send that data in logout API 16) Dynamic menu based on roles — one route accessible by multiple roles and Guards for role-based access 17) Project uses PrimeNG but needs migration to Angular Material — how will you plan and manage branching without affecting sprints 18) How comfortable are you with external libraries like AG Grid, PrimeNG, graph libraries For Senior role we have to be ready to Question like these not just basics. If you find this helpful, follow me Chetan Jogi for more Angular interview questions and feel free to repost to help others. #angular #angularInterview #frontendDeveloper #javaScript #RxJS #javascriptInterview #angularDeveloper #angularjobs
To view or add a comment, sign in
-
React.js Interview Questions ? Today’s focus Custom Hooks in React — a very popular FAANG interview topic to test code reusability & clean architecture. Problem Statement Create a reusable logic to handle API fetching (loading, error, data). Custom Hook + Clean Code Solution import { useState, useEffect } from "react"; // Custom Hook function useFetch(url) { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchData = async () => { try { setLoading(true); const response = await fetch(url); const result = await response.json(); setData(result); } catch (err) { setError("Something went wrong"); } finally { setLoading(false); } }; fetchData(); }, [url]); return { data, loading, error }; } // Component Usage function App() { const { data, loading, error } = useFetch( "https://lnkd.in/eb7DsqQu" ); if (loading) return <p>Loading...</p>; if (error) return <p>{error}</p>; return ( <ul> {data.map((user) => ( <li key={user.id}>{user.name}</li> ))} </ul> ); } export default App; Interview Concepts Covered: - Custom Hooks (Code Reusability) - Separation of Concerns - API Handling (Loading, Error, Data) - Clean & Scalable Architecture Interview Questions: - What are Custom Hooks? Why do we use them? - Difference between Custom Hook vs Utility Function? - Can we use hooks inside loops/conditions? (No) - How to make this hook more reusable (pagination, caching)? Key Takeaway: Top companies expect you to write clean, reusable, and scalable code, not just working solutions. #ReactJS #FrontendInterview #CustomHooks #WebDevelopment #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
JavaScript Closures: The Interview Question That Separates Juniors from Seniors 🔒 Stop memorizing definitions. Start explaining like a pro. The 30-Second Interview Answer: 📌 Definition A closure is a function that "remembers" its lexical scope even when executed outside that scope. 📌 The Structure ```javascript function outer() { let secret = "private"; return function inner() { return secret; // Closure! }; } const closure = outer(); console.log(closure()); // "private" ``` 📌 Real-World Use Debouncing search inputs – prevents API calls on every keystroke: ```javascript function debounce(fn, delay) { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => fn(...args), delay); }; } // Saves $$$ on API costs! ``` 📌 Why It Matters • Encapsulation – private variables without classes • Performance – debounce/throttle events • State persistence – remembers values across calls 📌 Senior-Level Insight "Closures are powerful but can cause memory leaks if not cleaned up. Always remove event listeners and nullify references when components unmount." The Bottom Line: Closures aren't just theory – they're the foundation of React Hooks, event handlers, and efficient JavaScript. --- 💡 Interview Tip: When asked about closures, always follow with a real-world example. Theory proves you studied. Application proves you code. Found this useful? ♻️ Share with someone preparing for interviews. Follow me for more JavaScript deep dives! #JavaScript #WebDevelopment #CodingInterview #TechCareers #FrontendDeveloper
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