Event loop in NodeJS ? 🧠 Call Stack – where JS runs your code line by line. 📦 Web APIs / Node APIs – handle async stuff like setTimeout, fetch, etc. 📬 Callback Queue (Task Queue) – stores async callbacks waiting to run. 🔁 Event Loop – constantly checks if the stack is empty, and if yes, moves queued tasks back into it. Flow: - Synchronous code block the call stack, so it run first. - When it encounters async function (setTimeout, file I/O or HTTP request) it is send to Web APIs, which handle the operation in background. - The Call Stack does not wait for async function to finish and it moves to next line immediately. - Once the Call Stack is empty, the event loop first checks Microtask Queue (Promises, Process.NextTick). - Finally, the Event Loop process the Callback Queue(e.g., setTimeout, file I/O callbacks). #JavaScript #NodeJS #BackendDevelopment #AsyncProgramming #WebDevelopment #MERNStack #EventLoop #CleanCode #SoftwareEngineering #100DaysOfCode
NodeJS Event Loop Explained
More Relevant Posts
-
Node.js – Day 7/30 Call Stack, Callback Queue & Microtask Queue To really understand how async code works in Node.js, it’s important to know what happens behind the scenes. Call Stack o) Executes synchronous code o) Runs one function at a time o) Must be empty before async callbacks are executed Callback (Task) Queue o) Holds callbacks from async operations like setTimeout and I/O o) These are executed after the call stack is clear Microtask Queue o) Holds promise callbacks (.then, catch, finally) o) Has higher priority than the callback queue Execution order: 1). Call Stack 2). Microtask Queue 3). Callback Queue This explains why promise-based code often runs before timers. #NodeJS #EventLoop #JavaScript #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
🚀 Next.js API Routes: Backend in 5 Minutes Tired of separate Express servers? Next.js API Routes let you build full-stack apps with zero config. Your first API endpoint (3 lines): js // pages/api/hello.js export default function handler(req, res) { res.status(200).json({ message: 'Hello from Next.js!' }) } http://localhost:3000/api/hello ✅ Done. What you'll learn in my new guide: ✅ Create GET/POST endpoints ✅ Handle different HTTP methods ✅ Dynamic routes [id].js ✅ Form processing & database calls ✅ Production deployment tips Real-world use cases covered: Contact forms Database CRUD operations Third-party API integrations Authentication endpoints Perfect for: Next.js beginners ➡️ full-stack devs React devs ➡️ backend freedom Read the complete tutorial: https://lnkd.in/g_gAkasr Next.js devs: What's your favorite API route use case? Forms? Auth? Data fetching? Drop it below! 👇 #NextJS #API #FullStack #JavaScript #WebDevelopment #React 📌 Pro Tip: Use req.method to handle GET/POST/PUT/DELETE in one file! js if (req.method === 'POST') { /* save data */ } else if (req.method === 'GET') { /* fetch data */ }
To view or add a comment, sign in
-
Day 6 – Node.js Understanding async/await Today’s topic: async/await in Node.js. async/await is built on top of Promises and makes asynchronous code easier to read and maintain. Instead of using .then() and .catch(), we can write asynchronous code that looks like synchronous code. Key points: • async makes a function return a Promise • await pauses execution until the Promise resolves • Error handling is done using try/catch • Avoids callback nesting async/await improves readability and structure in real-world backend applications. Next: Node.js Core Modules (fs, path, os) #NodeJS #BackendDevelopment #JavaScript #AsyncProgramming #SoftwareEngineering
To view or add a comment, sign in
-
-
This diagram shows how a client sends a request, how the Node.js server processes it, and how the response is sent back. Node.js allows JavaScript to run on the server and handle multiple requests efficiently using a non-blocking approach. Save this post if you’re learning backend development. #NodeJS #BackendDevelopment #WebDevelopment #JavaScript #ProgrammingConcepts #LearnToCode #SoftwareDevelopment #TechLearning
To view or add a comment, sign in
-
Bun vs Node.js 👀 The JavaScript performance conversation is changing. ⚡ ~98,000 requests/sec vs Node’s ~36,000 🧠 ~66% lower peak memory usage in comparable workloads 📦 Up to 30× faster package installs with global caching + native hardlinks 🟦 Native TypeScript & JSX support out of the box 🧰 Runtime + bundler + package manager in one fast binary Node.js is still rock-solid, battle-tested, and everywhere. But Bun is clearly pushing the limits on speed, DX, and simplicity. Benchmarks vary by workload, but the trend is hard to ignore: Bun is fast — especially for modern backends and tooling-heavy projects. Curious to hear from the community: Are you experimenting with Bun already, planning a migration, or sticking with Node for now? ⚡ Team Bun 🛤️ Team Node #BunJS #NodeJS #JavaScript #Backend #WebDevelopment #TypeScript #Performance #DevTools
To view or add a comment, sign in
-
-
When you are building on any JavaScript application (for example Node.js or ReactJS), you quickly discover two files package.json and package-lock.json. These two files are very important and form the backbone of dependency management in your project to ensure your project runs smoothly whether you're developing locally or deploying to a server. 📜 package.json: The Project Passport The package.json file is the manifest file of your Node.js project. It's a simple JSON file that sits in the root directory of your project and contains metadata about your application along with a list of dependencies your project requires to function. 🔒 package-lock.json: The Security Seal While package.json is flexible, the lock file is absolute. It is automatically generated to record the exact versions of every single dependency in your project tree. Check out my latest blog post for a deep dive! 🔗 https://lnkd.in/gDnFHsKX #NodeJS #WebDevelopment #JavaScript #CodingTips #NPM #DevOps #SoftwareEngineering
To view or add a comment, sign in
-
-
Most beginners struggle with Node.js not because it’s hard, but because core concepts are misunderstood or skipped. Async flow, request/response cycles, middleware, and error handling form the foundation of Node — and everything breaks without them. Understanding why these concepts exist makes Node feel logical instead of confusing. Next post: Before building APIs in Node, understand this #nodejs #javascript #webdevelopment #learninginpublic #beginners #backend
To view or add a comment, sign in
-
𝗕𝘂𝗻 𝘃𝘀 𝗡𝗼𝗱𝗲.𝗷𝘀: 𝗜𝘀 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗕𝗮𝗰𝗸𝗲𝗻𝗱 𝗘𝗻𝘁𝗲𝗿𝗶𝗻𝗴 𝗮 𝗡𝗲𝘄 𝗘𝗿𝗮? The JavaScript backend ecosystem is evolving fast — and Bun has entered the conversation in a big way. So how does it really compare with Node.js? 𝗡𝗼𝗱𝗲.𝗷𝘀 Node.js has been the backbone of JavaScript backend development for years. Powered by the V8 engine, backed by a massive ecosystem, and trusted in production at scale. Stable, battle-tested, and still the default choice for most teams. 𝗕𝘂𝗻 Bun is a modern runtime built for speed. It ships with a fast JavaScript engine, built-in TypeScript support, an integrated bundler, and a lightning-fast package manager — all in one tool. The focus is clear: performance, simplicity, and developer experience. 💡 The real question isn’t “Bun vs Node” It’s when and where to use each. Node.js → reliability, ecosystem, enterprise adoption Bun → speed, modern tooling, rapid development The future may not replace Node.js — but Bun is definitely pushing the JavaScript backend forward. #BunJS #NodeJS #JavaScript #BackendDevelopment #WebDevelopment #FullStackDeveloper #TechTrends #SoftwareEngineering
To view or add a comment, sign in
-
-
Node.js – Day 5/30 Blocking vs Non-Blocking I/O One of the most important ideas in Node.js is the difference between blocking and non-blocking operations Blocking I/O: o) The program waits until a task completes o) The main thread is blocked o) Other requests must wait Non-Blocking I/O (Node.js default): o) The task is started and delegated o) The main thread continues processing other requests o) Results are handled asynchronously when ready Why this matters in Node.js: o) Prevents the event loop from getting stuck o) Allows better concurrency with fewer resources o) Improves performance for I/O-heavy applications This concept explains why Node.js performs well for APIs, file handling, and real-time services. #NodeJS #BackendDevelopment #JavaScript #NonBlockingIO #LearningInPublic
To view or add a comment, sign in
-
🚀 Just created a beginner-friendly Node.js Complete Guide covering core concepts and how to move towards Express.js framework for backend development! In this guide, I’ve explained: ✅ What is Node.js & why it’s popular ✅ Client-side vs Server-side (Node.js concept) ✅ How Node.js works internally (Event Loop, V8 Engine, Non-blocking architecture) 📌 After learning these Node.js basics, the next step is Express.js — a powerful Node.js framework used to: ✔ Build APIs ✔ Handle routes easily ✔ Manage backend logic efficiently This roadmap helps beginners smoothly move from JavaScript → Node.js → Express.js → Backend Development. #NodeJS #ExpressJS #BackendDevelopment #JavaScript #WebDevelopment #LearningJourney #MERNStack #DjangoToNode #TechSkills #RiyaSharma
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