Day 14 #100DaysOfCode 💻 Today I learned Promise & Async/Await in JavaScript. Promise helps handle asynchronous operations like API calls. Async/Await makes code cleaner and easier to read. Example: function getData() { return new Promise((resolve) => { setTimeout(() => { resolve("Data received"); }, 1000); }); } async function fetchData() { const result = await getData(); console.log(result); } fetchData(); Now I can handle async code without messy callbacks 🚀 #JavaScript #AsyncAwait #Promise #WebDevelopment #CodingJourney #Akbiplob
Mastering Promise & Async/Await in JavaScript
More Relevant Posts
-
hi connections Day 16 of 30: Implementing a Promise Time Limit! Moving deeper into the Asynchronous section of my 30 Days of JavaScript on LeetCode. Today was about adding a "safety net" to our code. 🛠️⏳ The Goal: Wrap an async function so that if it takes longer than a specified time t, it immediately fails with a "Time Limit Exceeded" error. The Lesson: I used Promise.race() to pit the actual function against a custom timeout promise. This pattern is crucial for building resilient systems. Whether it's a web crawler or a high-traffic API, you never want one slow request to block your entire event loop. Control the time, control the performance! 💻🔥 #JavaScript #WebDevelopment #CodingChallenge #LeetCode #Day16 #SoftwareEngineering #AsyncJS #PerformanceOptimization
To view or add a comment, sign in
-
-
The spread operator looks like this: ... The rest operator looks like this: ... They're identical. But they do opposite things. Spread = Expands outward Rest = Collects inward I wrote a detailed guide breaking down both with real examples: Array & object spreading patterns Rest parameters & destructuring Practical use cases (React, APIs, function forwarding) Why context matters Simple rule: Use spread to unpack. Use rest to gather. 🔗 Read here: https://lnkd.in/gnMgH-zR More JavaScript fundamentals on Hashnode: https://lnkd.in/gAwxuryw Inspired by @Hitesh Choudhary @Piyush Garg @ChaiCode #JavaScript #ES6 #WebDevelopment
To view or add a comment, sign in
-
-
Day 12/100 of JavaScript 🚀 Today’s topic: async / await "async" and "await" provide a cleaner way to work with Promises and write asynchronous code that looks like synchronous code 📍Basic example async function getData() { const res = await fetch("https://lnkd.in/gCA7VyNQ"); const data = await res.json(); console.log(data); } 📍With error handling async function getData() { try { const res = await fetch("https://lnkd.in/gCA7VyNQ"); const data = await res.json(); console.log(data); } catch (err) { console.error(err); } } 🔑 Key points : - "async" makes a function return a Promise. - "await" pauses execution until the Promise resolves. - Makes code more readable than ".then()" chaining. async/await simplifies handling asynchronous operations while still using Promises under the hood. #Day12 #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
🚀 Day 4/30 – JavaScript Challenge Solved: Counter II (LeetCode 2665) Today’s problem was all about understanding closures and how functions can maintain their own state in JavaScript. What I learned: 1.How closures help preserve variable values across function calls 2.Creating multiple operations (increment, decrement, reset) using a single function 3.Clean use of arrow functions for concise code Approach: I created a function that stores the initial value and returns an object with three methods: 1.increment() -> increases value 2.decrement() -> decreases value 3.reset() -> resets to initial value All of this works because of closure, where the inner functions still remember the variable n. Key Insight: Closures are powerful when you need to encapsulate data and control how it’s modified — a very common pattern in real-world JavaScript applications. Consistency is the real game here 🔥 Let’s keep building, one day at a time. #Day4 #30DaysOfCode #JavaScript #WebDevelopment #CodingChallenge #LeetCode #Closures #LearningJourney
To view or add a comment, sign in
-
-
Fixed a bug today that took hours to understand. API was fine. Frontend looked correct. But data wasn’t showing. Issue? A small mismatch in field names. Lesson: • Always verify API responses • Never assume things are correct Small bugs, big lessons. What did you debug recently? #FullStackDeveloper #WebDevelopment #JavaScript #Debugging #ProblemSolving
To view or add a comment, sign in
-
💡 𝗧𝗶𝗽 𝗼𝗳 𝘁𝗵𝗲 𝗗𝗮𝘆 — 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗗𝗶𝗱 𝘆𝗼𝘂 𝗸𝗻𝗼𝘄? "Object.freeze()" makes an object 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲 — but only at the top level. That means: - You 𝗰𝗮𝗻𝗻𝗼𝘁 𝗮𝗱𝗱, 𝗿𝗲𝗺𝗼𝘃𝗲, 𝗼𝗿 𝗰𝗵𝗮𝗻𝗴𝗲 properties on the frozen object - But 𝗻𝗲𝘀𝘁𝗲𝗱 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 𝗰𝗮𝗻 𝘀𝘁𝗶𝗹𝗹 𝗯𝗲 𝗺𝗼𝗱𝗶𝗳𝗶𝗲𝗱 🔧 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁: If you need full immutability, you’ll need a 𝗱𝗲𝗲𝗽 𝗳𝗿𝗲𝗲𝘇𝗲 (or use libraries like Immer). Shallow vs deep immutability — a small detail that can cause big bugs. #JavaScript #FrontendDevelopment #WebDevelopment #SoftwareEngineering #CodingTips #CleanCode #BestPractices #FullstackDeveloper
To view or add a comment, sign in
-
-
🚀 Day 67 | JavaScript Loops & Array Iteration Today I practiced JavaScript loops and working with arrays of objects 💻 🔹 What I Worked On: • Iterated through array of objects using for loop • Printed all elements and accessed object properties like loc • Used loop with step increment (i += 2) to print alternate values • Practiced reverse counting using for and while loops • Used forEach() for cleaner array iteration 💡 Key Learning: • Arrays of objects are very common in real-world applications • Loop conditions must be handled carefully (i < length vs <= length) • forEach() is simple and readable for iteration • Multiple ways to loop → choose based on requirement 🔥 Takeaway: 👉 Mastering loops is key to handling data efficiently in JavaScript Consistency is improving logic step by step 🚀 #Day67 #JavaScript #Loops #ArrayIteration #ProblemSolving #CodingJourney #10000Coders #WebDevelopment #SravanKumarSir
To view or add a comment, sign in
-
🚀 Day 968 of #1000DaysOfCode ✨ Types of Loops in JavaScript (Explained Simply) Loops are one of the most fundamental concepts in JavaScript — but choosing the right one can make a big difference in your code. In today’s post, I’ve explained the different types of loops in JavaScript in a simple and practical way, so you can understand when to use each one. From `for` and `while` to `for...of` and `for...in`, each loop has its own purpose depending on how you’re working with data. Using the right loop not only makes your code cleaner but also improves readability and performance in many cases. This is one of those basics that every developer uses daily — but mastering it helps you write much better code. If you’re working with arrays, objects, or complex data structures, this is something you should be confident about. 👇 Which loop do you use the most in your day-to-day coding? #Day968 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #JSBasics
To view or add a comment, sign in
-
🔥 JavaScript Devs — Mutation vs Immutability (The Silent Bug Creator) Hey devs 👋 This one caused me real production bugs… 👉 Mutation in JavaScript. Example: const obj = { value: 1 }; const newObj = obj; newObj.value = 2; 💥 Now BOTH objects changed. 👉 Problem: Shared references → unexpected side effects 💡 What I changed: ✔ Use spread operator ✔ Avoid direct mutation ✔ Treat state as immutable Example: const newObj = { ...obj, value: 2 }; ⚡ Lesson: “Mutation is easy… debugging it is not.” 👉 Senior mindset: Predictable data = predictable code Have you faced mutation bugs before? #javascript #immutability #programmingtips #webdevelopment #frontenddeveloper #backenddeveloper #cleancode #softwareengineering #codingbestpractices #jsdeepdive #learn
To view or add a comment, sign in
-
-
🚀 From Arrays to Efficiency: Mastering Set in JavaScript Today I solved the “Unique Rows in Boolean Matrix” problem using one simple yet powerful concept — Set. At first glance, the problem looks like a typical nested loop challenge. But instead of going brute force, I leveraged Set to achieve a clean and optimal solution. 💡 Key Idea: Convert each row into a string and store it in a Set to automatically handle duplicates. ✨ Why this is powerful: Eliminates duplicates in O(1) lookup time Avoids unnecessary nested loops Keeps the solution clean and readable 📊 Complexity: Time: O(n × m) Space: O(n × m) 🔥 Takeaway: Sometimes, the difference between an average solution and an optimal one is just knowing the right data structure. Today it was Set. Tomorrow, it could be something else. 💬 Curious: Where else have you used Set to simplify a problem? #JavaScript #DSA #CodingInterview #WebDevelopment #ProblemSolving #100DaysOfCode
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