Day 13 #100DaysOfCode 💻 Today I learned about JavaScript Promises. Promises are objects that handle asynchronous operations and have three states: pending, fulfilled, and rejected. They make async code more readable compared to callbacks. let promise = new Promise((resolve, reject) => { let success = true; success ? resolve("Task completed!") : reject("Task failed!"); }); promise .then(result => console.log(result)) .catch(error => console.log(error)); It feels great to finally understand how async tasks can be managed smoothly with promises! #JavaScript #WebDevelopment #Akbiplob
Understanding JavaScript Promises for Async Code
More Relevant Posts
-
Day 11/100 of JavaScript 🚀 Today’s topic: Promises A Promise represents the result of an asynchronous operation It has 3 states: - Pending - Fulfilled - Rejected 🔹Creating a Promise const promise = new Promise((resolve, reject) => { let success = true; if (success) { resolve("Done"); } else { reject("Error"); } }); 🔹Consuming a Promise promise .then(result => console.log(result)) .catch(error => console.error(error)); 🔹Chaining fetch(url) .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err)); Promises help handle asynchronous operations in a structured way and avoid deeply nested callbacks. #Day11 #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
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
-
-
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
To view or add a comment, sign in
-
Day 9 of #JavaScript30💻 Today I explored various console tricks in JavaScript that help developers debug faster and understand program behavior more clearly. Instead of using only console.log(), I learned how the browser console provides several useful tools such as: • console.info() -> to display informational messages • console.assert() -> to test conditions inside code • console.group() / console.groupCollapsed() -> to organize logs neatly • console.count() -> to track how many times something runs • console.time() / console.timeEnd() -> to measure execution time • console.table() -> to display arrays and objects in structured table format These tools make debugging cleaner, faster, and more professional during development. #JavaScript #JavaScript30 #WebDevelopment #FrontendDevelopment #LearningInPublic #CodingJourney
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
-
TypeScript 6.0 just dropped So yes, developers everywhere are once again opening tsconfig.json like it is a legal document they forgot to read properly. What I like about this release is that it is not pretending to be some flashy revolution. TypeScript 6.0 is explicitly positioned as a bridge between 5.9 and the upcoming 7.0 native rewrite, but it still brought a few genuinely nice additions. A couple of things that stood out to me: - support for es2025 in both target and lib - built-in types for the long-awaited Temporal API - dom.iterable is basically folded into dom, which removes one of those tiny configuration details nobody truly enjoyed explaining to teammates It also has strong “please clean up your setup before 7.0” energy 😊 strict is now true by default, the default module is now esnext, the default target moves to the current supported ECMAScript version, and old import assertion syntax is deprecated in favor of with. Even when it gives you new features, it still manages to sound like a very smart coworker gently judging your 2021 config decisions. #typescript #javascript #webdev #frontend #softwareengineering
To view or add a comment, sign in
-
-
🚀 𝗪𝗵𝗼 𝗘𝘅𝗲𝗰𝘂𝘁𝗲𝘀 𝗙𝗶𝗿𝘀𝘁 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁? 🚀 I’ve just shared a handy guide—“Who Executes First in JavaScript: Synchronous, Microtasks & Macrotasks”—to help you predict exactly when your code runs and avoid those nagging timing bugs. 𝗠𝗮𝗶𝗻 𝘁𝗮𝗸𝗲𝗮𝘄𝗮𝘆𝘀: - 𝗦𝘆𝗻𝗰 𝗳𝗶𝗿𝘀𝘁: Plain console.log calls run immediately in sequence. - 𝗠𝗶𝗰𝗿𝗼𝘁𝗮𝘀𝗸𝘀 𝗻𝗲𝘅𝘁: Promises (and await continuations) always beat macrotasks. - 𝗠𝗮𝗰𝗿𝗼𝘁𝗮𝘀𝗸𝘀 𝗹𝗮𝘀𝘁: Even setTimeout(..., 0) waits until after all sync and microtasks. Want to see this in action? Check out the slide deck for live code examples—and let me know which timing gotcha has tripped you up the most! #javascript
To view or add a comment, sign in
-
"𝗡𝗼𝗱𝗲.𝗷𝘀 𝗶𝘀 𝗮 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗿𝘂𝗻𝘁𝗶𝗺𝗲." 𝗬𝗼𝘂'𝘃𝗲 𝗿𝗲𝗮𝗱 𝗶𝘁 𝟭,𝟬𝟬𝟬 𝘁𝗶𝗺𝗲𝘀, 𝗯𝘂𝘁 𝗱𝗼 𝘆𝗼𝘂 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗴𝗲𝘁 𝗶𝘁? 🧐 The word "Runtime" is a trap because it describes two completely different things: 1️⃣ 𝗔 𝗠𝗼𝗺𝗲𝗻𝘁 𝗶𝗻 𝗧𝗶𝗺𝗲: The execution phase (when those "runtime errors" actually explode). 2️⃣ 𝗔𝗻 𝗘𝗻𝘃𝗶𝗿𝗼𝗻𝗺𝗲𝗻𝘁: The engine (V8/JSC) + APIs (Node/Bun/Deno) that let your code run outside the browser. Confusion here leads to "ghost bugs." Mastering the difference is what separates a dev who just "follows tutorials" from one who truly understands 𝗦𝗼𝗳𝘁𝘄𝗮𝗿𝗲 𝗔𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲. I’ve written a jargon-free guide to clear the fog. We compare how engines like V8 vs. JavaScriptCore change the game for tools like Node, Deno, and Bun. 👉 𝗦𝗮𝘃𝗲 𝘁𝗵𝗲 𝗶𝗻𝗳𝗼𝗴𝗿𝗮𝗽𝗵𝗶𝗰 𝗯𝗲𝗹𝗼𝘄 as your quick reference guide! 🔗 𝗥𝗲𝗮𝗱𝘆 𝘁𝗼 𝗺𝗮𝘀𝘁𝗲𝗿 𝘁𝗵𝗲 𝗰𝗼𝗻𝗰𝗲𝗽𝘁? Read the full article on the Blueprint blog. 👇 𝗟𝗶𝗻𝗸 𝗶𝗻 𝘁𝗵𝗲 𝗳𝗶𝗿𝘀𝘁 𝗰𝗼𝗺𝗺𝗲𝗻𝘁! #JavaScript #WebDev #NodeJS #SoftwareEngineering #BlueprintBlog
To view or add a comment, sign in
-
-
tjs-lang passed a couple of milestones over the last few days. It can already transpile itself, so it’s “self-hosted”. It can now transpile tosijs’s codebase and it can capture and re-emit ts declarations, while adding metadata to the tjs intermediate code to help anyone migrating from ts to tjs to replace complex generic types with simple predicates. Along the way tjs helped nail down a subtle and hard to replicate bug that has lingered for years. And then we decided to transpile a bunch of thorny libraries starting with Zod and ending with Effect.js (120k loc and truly perversely complex types). #javascript #typescript
To view or add a comment, sign in
-
TypeScript 6.0 is your final warning TypeScript 6.0 has been released as the last version built on its JavaScript codebase, serving as a transition before TypeScript 7.0 introduces a Go-based compiler with native speed and multi-threaded type checking. Key changes include strict mode enabled by default, module defaulting to esnext, target floating to the current ES spec (es2025), and types defaulting to an empty array — a change that may break many projects but promises 20–50% speed improvements. New features include built-in Temporal API types and Map.getOrInsert support. Several legacy options like outFile, baseUrl, and AMD/UMD/SystemJS targets are deprecated or removed. The newsletter also covers pnpm 11 beta, Zero 1.0 stable release, a React useState closure gotcha, and various other JavaScript ecosystem links
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