🚀 Learning by Building: JavaScript Promises (From Scratch) Today, I deepened my understanding of how JavaScript Promises work internally by building a custom Promise implementation from scratch. Instead of just using .then() and .catch(), I explored: > How the promise state (pending → fulfilled/rejected) changes > How handlers are stored and executed > Why asynchronous execution (microtasks/macrotasks) matters > How adding console logs helps visualize the async flow clearly This hands-on approach really helped me understand why Promises behave the way they do, not just how to use them. 🔍 Key takeaway: If you can build it, you truly understand it. Looking forward to diving deeper into promise chaining, error handling, and async/await internals next 💡 #JavaScript #LearningInPublic #WebDevelopment #AsyncProgramming #Frontend #DeveloperJourney
Understanding JavaScript Promises from Scratch
More Relevant Posts
-
🚀 Mastering JavaScript Variables: var vs let vs const Understanding JavaScript variables is essential for writing clean, modern, and error-free code. 🔸 var – Function scoped, redeclarable. Avoid in modern JS. 🔹 let – Block scoped, flexible, best for changeable values. 🔒 const – Block scoped, secure, best for fixed values. 💡 Best Practice: Use const by default, let when value changes, and avoid var. #JavaScript #WebDevelopment #Coding #MERNStack #Frontend #Learning
To view or add a comment, sign in
-
-
After working with JavaScript arrays for a while, I’ve realised something simple —clean code > complex logic. Two small but powerful tools I use often: 1) reduce() When you want to turn an entire array into a single result, reduce() is a game changer. Instead of writing loops and extra variables, you can accumulate values in one clean line. It’s not just for sums. You can use it for counting, grouping, transforming data — almost anything that needs accumulation logic. 2) Set() Handling duplicate values? No need for complex checks. Simple. Readable. Efficient. What I like most about these methods is this: They make code expressive. Still learning. Still building. 🚀 #JavaScript #WebDevelopment #Frontend #MERNStack
To view or add a comment, sign in
-
-
A callback function is a function that is passed as an argument to another function and executed after a task is completed. Callbacks are the backbone of asynchronous JavaScript. They help handle tasks like: ⏱️ Timers (setTimeout) 🌐 API calls 🖱️ Event handling Without callbacks, JavaScript would block execution and slow everything down. ⚠️ Too many nested callbacks can lead to callback hell, which is why we later use Promises and Async/Await. Understanding callbacks = understanding how JavaScript really works 🚀 Nishant Pal #JavaScript #WebDevelopment #Frontend #AsyncJS #Coding #LearnJavaScript
To view or add a comment, sign in
-
-
🚀 Mini JavaScript Project: Calculator As part of my JavaScript recap at NTI, I built a simple calculator using only functions and variables. This project helped me revisit the fundamentals and strengthen my understanding of core JS concepts. 💡 Key Takeaways: Structuring functions for different operations Using variables to store and manipulate data Practicing clean and readable code 📂 Check it out on GitHub: https://lnkd.in/dgj7pyuq 🌐 Live Demo: https://lnkd.in/dDANENcr Excited to keep applying these skills to more advanced projects! #javascript #frontend #NTI
To view or add a comment, sign in
-
JavaScript is single-threaded, yet it handles async tasks smoothly. The magic lies in how the JavaScript runtime manages execution 👇 🔹 Call Stack Executes synchronous code line by line (LIFO). 🔹 Microtask Queue Handles high-priority tasks like Promise.then(), catch(), and queueMicrotask(). It Always executed before macrotasks. 🔹 Macrotask (Event) Queue Contains tasks like setTimeout, DOM events, and setInterval. 🔁 Event Loop Keeps checking: 1️⃣ Is the call stack empty? 2️⃣ Run all microtasks 3️⃣ Execute one macrotask That’s why Promises run before setTimeout, even with 0ms. Nishant Pal #JavaScript #EventLoop #AsyncProgramming #WebDevelopment #Frontend #CodingLife #DevTips #Promises
To view or add a comment, sign in
-
-
Week 4 | Web Development (ChaiCode Cohort) This week was focused on JavaScript fundamentals and understanding what actually happens behind the scenes when JS code runs: 🔹️ How JavaScript code executes internally 🔹️Global & Local Execution Context 🔹️Call stack basics 🔹️Temporal Dead Zone (TDZ) with let and const 🔹️Difference between var, let, and const 🔹️Function execution and scope basics Understanding execution context and TDZ cleared up a lot of confusion around unexpected errors and variable behavior. Next week: deeper JavaScript concepts + more practice. Thanks to Hitesh Choudhary sir and Piyush Garg for simplifying complex internals. #JavaScript #WebDevelopment #Learning #ChaiCode #Frontend #Consistency
To view or add a comment, sign in
-
-
🚀 Understanding JavaScript Async: Callback vs Promise vs Async/Await Many beginners get confused about callbacks, promises, and async/await — so here’s a simple way to remember 👇 👉 All three are ASYNCHRONOUS They are just different ways to handle async operations in JavaScript. 🔹 Callback ☎️ “Call me back when the task is done.” ➡️ Works, but leads to callback hell and messy code. 🔹 Promise 🤝 “I promise I’ll give you the result later.” ➡️ Cleaner with .then() and .catch() chaining. 🔹 Async / Await ⏳ “Wait here, then continue.” ➡️ Modern, readable, and easiest to maintain. 📌 Key takeaway: Async/Await does NOT make code synchronous — it only makes async code look synchronous. If you’re learning JavaScript or React, mastering async concepts is a game changer 💡 #JavaScript #WebDevelopment #AsyncAwait #Promises #Frontend #Coding
To view or add a comment, sign in
-
-
While revisiting JavaScript fundamentals, I came across a detail about setInterval() that’s easy to miss. In the attached example, the interval executes every 2 seconds. Since setInterval() runs indefinitely by default, I used setTimeout() only to stop it after 10 seconds by calling clearInterval(). This allows the task to run exactly 5 times and then exit cleanly. Why this matters: -> setInterval() does not manage its own lifecycle -> The interval ID must be preserved to stop execution -> Explicit cleanup leads to predictable and maintainable code Small patterns like this play a big role in real-world applications, where uncontrolled intervals can quietly introduce bugs or unnecessary work. Sharing this as part of my learning journey — revisiting fundamentals often uncovers details that make a real difference in code quality. Learning continuously, improving intentionally 🚀📈 #JavaScript #WebDevelopment #FrontendDevelopment #LearningInPublic #CleanCode #SoftwareEngineering #Developers #Fullstackdev
To view or add a comment, sign in
-
-
🧠 Why JavaScript feels confusing at first Almost everyone learning JavaScript feels this: “I understand the syntax… but I don’t understand what’s happening.” 😵💫 JavaScript feels confusing because 👇 1️⃣ It is event-driven (clicks, inputs, time) 2️⃣ Code doesn’t always run top to bottom 3️⃣ Variables can change over time 4️⃣ The browser and JavaScript work together 💡 The mindset shift that helps: ❌ “What does this line do?” ✅ “When does this code run, and why?” Once you start thinking in events + flow, JavaScript becomes much clearer. Don’t rush JS. Understand how it thinks 🚀 #JavaScript #Frontend #WebDevelopment #LearnJS #LearningInPublic
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