🚀 Day 21/100 – Implementing Promise.race() in JavaScript Today I explored another important Promise method: Promise.race() It returns the result of the first settled promise (either resolved or rejected). 🧠 Problem: Create a custom implementation of Promise.race(). ✅ Solution: function myPromiseRace(promises) { return new Promise((resolve, reject) => { promises.forEach((promise) => { Promise.resolve(promise) .then(resolve) .catch(reject); }); }); } // Example const p1 = new Promise((res) => setTimeout(() => res("First"), 1000)); const p2 = new Promise((res) => setTimeout(() => res("Second"), 500)); myPromiseRace([p1, p2]) .then((data) => console.log(data)) .catch((err) => console.error(err)); ✅ Output: Second (Because it resolves faster) 💡 Key Learnings: • Returns the first settled promise (resolve or reject) • Does NOT wait for all promises • Useful for timeouts and fallback strategies • Works well in race conditions 📌 Real World Usage: • API timeout handling • Loading fastest resource • Fallback mechanisms • Performance optimization Understanding Promise utilities helps in writing better async logic and handling real-world scenarios. I’m currently open to Frontend Developer opportunities (React / Next.js) and available for immediate joining. 📩 Email: bantykumar13365@gmail.com 📱 Mobile: 7417401815 If you're hiring or know someone who is, I’d love to connect. #OpenToWork #FrontendDeveloper #JavaScript #Promises #ReactJS #NextJS #ImmediateJoiner #100DaysOfCode
Implementing Promise.race() in JavaScript
More Relevant Posts
-
𝐌𝐨𝐬𝐭 𝐝𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫𝐬 𝐚𝐫𝐞 𝐮𝐬𝐢𝐧𝐠 𝐍𝐞𝐱𝐭.𝐣𝐬… 𝐛𝐮𝐭 𝐟𝐞𝐰 𝐚𝐫𝐞 𝐮𝐬𝐢𝐧𝐠 𝐢𝐭 𝐑𝐈𝐆𝐇𝐓 𝐰𝐢𝐭𝐡 𝐍𝐞𝐬𝐭𝐉𝐒. I’ve been building with Next.js + NestJS, and here’s the truth: 👉 Frontend without a solid backend = fragile apps 👉 Backend without structure = unscalable systems 👉 But combining both properly? That’s where things get powerful. 𝐇𝐞𝐫𝐞’𝐬 𝐰𝐡𝐚𝐭 𝐜𝐡𝐚𝐧𝐠𝐞𝐝 𝐦𝐲 𝐚𝐩𝐩𝐫𝐨𝐚𝐜𝐡: I stopped treating APIs as “just endpoints” I started building modular, scalable architectures I focused on type safety, performance, and real-world production patterns 𝐀𝐧𝐝 𝐡𝐨𝐧𝐞𝐬𝐭𝐥𝐲… 🔥 NestJS feels like what backend engineering should be. Clean architecture. Dependency injection. Enterprise-level structure - without the headache. 𝐂𝐮𝐫𝐢𝐨𝐮𝐬… Are you building full-stack apps the right way or just making things “work”? 𝗟𝗲𝘁’𝘀 𝘁𝗮𝗹𝗸: Are you team Next.js only or Next + NestJS? What’s your biggest backend struggle right now? 𝐈’𝐦 𝐜𝐮𝐫𝐫𝐞𝐧𝐭𝐥𝐲 𝐨𝐩𝐞𝐧 𝐭𝐨: Backend / Full-stack roles Collaborations Real-world projects where scalability actually matters If you're hiring or know someone who is - let’s connect 🤝 #NextJS #NestJS #FullStackDeveloper #SoftwareEngineering #WebDevelopment #TechCareers #OpenToWork #Developers #JavaScript #TypeScript
To view or add a comment, sign in
-
-
💡 JavaScript Tip – What is a Closure? Closures are one of the most powerful concepts in JavaScript. A closure is created when a function remembers variables from its outer scope, even after the outer function has finished executing. function outer() { let count = 0; return function inner() { count++; console.log(count); }; } const counter = outer(); counter(); // 1 counter(); // 2 counter(); // 3 🔹 Here, the inner function still has access to the count variable, even after outer has finished executing. 👉 This is called a closure. 📌 Where it is used? Data hiding Creating private variables Callbacks & event handlers Understanding closures helps you write better and more advanced JavaScript code. As a Frontend Developer with 2 years of experience in React.js, I enjoy learning and sharing core JavaScript concepts. Currently looking for Frontend Developer / React.js opportunities and available for immediate joining. #JavaScript #FrontendDeveloper #ReactJS #WebDevelopment #CodingTips #DeveloperTips #Closures #SoftwareDeveloper #TechLearning #OpenToWork #ImmediateJoiner #ITJobs #HiringNow
To view or add a comment, sign in
-
🚀 𝗦𝘁𝗼𝗽 𝗥𝗲-𝗿𝗲𝗻𝗱𝗲𝗿𝗶𝗻𝗴 𝗳𝗼𝗿 𝗘𝘃𝗲𝗿𝘆𝘁𝗵𝗶𝗻𝗴. 𝗦𝗼𝗺𝗲𝘁𝗶𝗺𝗲𝘀, 𝘆𝗼𝘂 𝗷𝘂𝘀𝘁 𝗻𝗲𝗲𝗱 𝘂𝘀𝗲𝗥𝗲𝗳. If you’re using useState for things like focusing inputs or accessing DOM elements… 👉 You might be doing it the hard way. Let’s talk about one of the most underrated hooks in React: useRef 👇 🔍 𝗪𝗵𝗮𝘁 𝗶𝘀 𝘂𝘀𝗲𝗥𝗲𝗳? 𝑢𝑠𝑒𝑅𝑒𝑓 gives you a way to 𝗱𝗶𝗿𝗲𝗰𝘁𝗹𝘆 𝗮𝗰𝗰𝗲𝘀𝘀 𝗮𝗻𝗱 𝗶𝗻𝘁𝗲𝗿𝗮𝗰𝘁 𝘄𝗶𝘁𝗵 𝗗𝗢𝗠 𝗲𝗹𝗲𝗺𝗲𝗻𝘁𝘀 — without causing re-renders. 👉 It returns a mutable object: 𝑐𝑜𝑛𝑠𝑡 𝑟𝑒𝑓 = 𝑢𝑠𝑒𝑅𝑒𝑓(𝑛𝑢𝑙𝑙); 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝗙𝗼𝗰𝘂𝘀 𝗮𝗻 𝗜𝗻𝗽𝘂𝘁 𝗙𝗶𝗲𝗹𝗱 𝑖𝑚𝑝𝑜𝑟𝑡 { 𝑢𝑠𝑒𝑅𝑒𝑓 } 𝑓𝑟𝑜𝑚 "𝑟𝑒𝑎𝑐𝑡"; 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝐴𝑝𝑝() { 𝑐𝑜𝑛𝑠𝑡 𝑖𝑛𝑝𝑢𝑡𝑅𝑒𝑓 = 𝑢𝑠𝑒𝑅𝑒𝑓(𝑛𝑢𝑙𝑙); 𝑐𝑜𝑛𝑠𝑡 ℎ𝑎𝑛𝑑𝑙𝑒𝐹𝑜𝑐𝑢𝑠 = () => { 𝑖𝑛𝑝𝑢𝑡𝑅𝑒𝑓.𝑐𝑢𝑟𝑟𝑒𝑛𝑡.𝑓𝑜𝑐𝑢𝑠(); }; 𝑟𝑒𝑡𝑢𝑟𝑛 ( <> <𝑖𝑛𝑝𝑢𝑡 𝑟𝑒𝑓={𝑖𝑛𝑝𝑢𝑡𝑅𝑒𝑓} /> <𝑏𝑢𝑡𝑡𝑜𝑛 𝑜𝑛𝐶𝑙𝑖𝑐𝑘={ℎ𝑎𝑛𝑑𝑙𝑒𝐹𝑜𝑐𝑢𝑠}>𝐹𝑜𝑐𝑢𝑠 𝐼𝑛𝑝𝑢𝑡</𝑏𝑢𝑡𝑡𝑜𝑛> </> ); } ✅ No state ✅ No re-render ✅ Direct DOM control 🔥 𝗪𝗵𝘆 𝗡𝗼𝘁 𝘂𝘀𝗲𝗦𝘁𝗮𝘁𝗲? ❌ 𝘂𝘀𝗲𝗦𝘁𝗮𝘁𝗲 ◦ Causes re-renders ◦ Not meant for direct DOM access ✅ 𝘂𝘀𝗲𝗥𝗲𝗳 ◦ No re-renders ◦ Perfect for DOM manipulation ◦ Stores values across renders 🔹 𝗖𝗼𝗺𝗺𝗼𝗻 𝗨𝘀𝗲 𝗖𝗮𝘀𝗲𝘀 ◦ Focusing input fields ◦ Measuring DOM elements ◦ Storing timers / intervals ◦ Persisting values without re-render ⚠️ 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗡𝗼𝘁𝗲 👉 Avoid overusing useRef for UI updates 👉 React prefers declarative code, not manual DOM manipulation 🔑 𝗙𝗶𝗻𝗮𝗹 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆 ◦ useState is for UI updates. ◦ useRef is for direct access without re-rendering. 💡 Part of my #FrontendRevisionMarathon — simplifying React concepts daily 🚀 🚀 Follow Shubham Kumar Raj for more such content. Have you used useRef beyond input focus? Share your use case 👇 #React #ReactJS #Frontend #WebDevelopment #JavaScript #FrontendRevisionMarathon #Performance #frontenddeveloper #codinginterview #programming #learnjavascript #interviewprep #CareerGrowth #SowftwareEngineering #Hiring #OpenToWork #Post #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Why do so many of us start our careers with Frontend Development? 💻 For many of us, Frontend feels like the easiest entry point into tech. You can quickly see what you’re building, understand the basics faster, and build confidence early in your journey. ✨ That’s how it started for me too. I began with Angular, then moved to React, and now I’m stepping ahead toward Node.js to grow into Full Stack development. 🌐 One of the biggest reasons is that JavaScript stays constant, so the transition feels much smoother. I feel many of us choose Frontend in the beginning of our careers because: 👨👩👧👦 A friend or family member was already working in that technology. 📌 Job openings were available for that stack. 🎥 There was a lot of video content and learning material available for it. ✅ You clearly understood the advantages of using that technology. 💸 The package offered was good. 📈 It had strong future scope. For me, Frontend was the starting point, but gradually the curiosity to build complete applications pushed me toward Full Stack. 🔥 🤔 What about you? Why did you choose Frontend in the initial phase of your career? Was it guidance, opportunities, salary, learning resources, future scope, or something else? #FrontendDevelopment #FullStackDevelopment #CareerGrowth #WebDevelopment #Angular #React #Nodejs #JavaScript #TechCareers
To view or add a comment, sign in
-
-
Over the past few years working with React.js, one thing has become very clear to me: 👉 It’s not just about building components — it’s about building efficient and scalable applications. Recently, while working on a project, I was able to improve performance by around 35%. Not by adding new features, but by refining what already existed: Better component structuring Using React Hooks effectively Reducing unnecessary re-renders Optimizing API integration This experience reinforced an important lesson: 💡 Clean architecture + performance-focused thinking = better user experience Currently focusing on: Writing scalable React.js applications Improving performance and maintainability Building reusable component systems Always learning and exploring better ways to build with React 🚀 #ReactJS #FrontendDeveloper #WebDevelopment #Performance #JavaScript #Learning #SDE #SoftwareEngineer #OpenToWork
To view or add a comment, sign in
-
I recently cut a React bundle size by 40%—without removing a single feature. Here’s the boring truth about Senior Frontend roles 👇 We love chasing shiny new libraries. New frameworks. Fancy abstractions. But after 6.5 years, I’ve learned this the hard way: High-performance products are built on discipline, not just tech stacks. When I was preparing for my switch, one thing became very clear: They weren’t hiring a “React Developer.” They were hiring a Problem Solver. So I treated my prep like a real-world system audit. Here’s the 3-step approach that made the difference: 1️⃣ Code Splitting (Beyond React.lazy) Not just lazy-loading routes—but analyzing what actually blocks first paint and splitting at meaningful boundaries. 2️⃣ Dependency Purge Removed or replaced heavy libraries with native CSS/JS where possible. (Yes, that 70kb utility library… gone.) 3️⃣ Memoization (With Intent) Used useMemo and useCallback only where the profiler proved a re-render problem—not as a default habit. No hype. No new framework. Just careful measurement + disciplined decisions. And that’s what actually moved the needle. If you're preparing for a switch, stop building “Todo Apps.” Start solving “Bundle Bloat.” Because that’s what real products struggle with. 💬 What’s one optimization that gave you a surprisingly big win recently? #WebPerformance #FrontendDevelopment #ReactJS #JavaScript #MERNStack #PerformanceOptimization #SoftwareEngineering #SystemDesign #CleanCode #Programming #CodingTips #DeveloperLife #TechCareers #ScalableSystems #FrontendEngineer #BuildInPublic #DevCommunity #TechInterview #SoftwareDeveloper
To view or add a comment, sign in
-
-
📘React.js Cheatsheet — Image + Full Explanation PDF (Free Resource) Are you a fresher trying to break into frontend development, or an experienced React dev looking for a structured refresher? I've put together a simple yet powerful React.js Cheatsheet that includes: ✅ Core Concepts (JSX, Virtual DOM, SPA) ✅ Hooks (useState, useEffect, useContext, etc.) ✅ API Handling (fetch, axios, REST vs GraphQL) ✅ Routing (React Router v6) ✅ Styling (Tailwind, Styled Components, CSS Modules) ✅ Lifecycle Methods & HOCs ✅ TypeScript with React V Project Ideas to Practice ✅ Common Mistakes to Avoid ✅ BONUS: Includes full-page breakdown in a downloadable PDF🔽 📧[Feel free to DM me for the PDF] or comment "React" below and l'il send it your way! 🔗 #Reactjs #FrontendDevelopment #WebDev #MERNStack #javascript #OpenSource #ReactDeveloper #100DaysOfCode #mohammedaskar #TechCommunity #ReactJs #LearningNeverStops #ReactCheatsheet
To view or add a comment, sign in
-
🚀 React JS in 2026 is NOT what you think… Most developers believe: 👉 “If I know React, I’m job-ready.” But here’s the reality 👇 React is no longer just about components, props, and hooks. 💡 The game has changed. Today, top React developers focus on: ⚡ Thinking in architecture, not just UI ⚡ Understanding server vs client rendering ⚡ Managing performance & caching, not just state ⚡ Connecting code with business impact Because in 2026… 👉 Companies don’t hire “React developers” 👉 They hire problem solvers who use React effectively And here’s the biggest mistake I see 👇 ❌ Building tutorial projects ❌ Copy-pasting code ❌ Ignoring real-world scalability Instead, focus on: ✅ Building production-level projects ✅ Learning system design basics ✅ Exploring tools like Next.js, APIs, and performance optimization ✅ Understanding why things work — not just how 🔥 React is still dominating the frontend world —but the expectations have evolved massively (LinkedIn) 💬 So here’s a question for you: Are you just learning React… or actually becoming a modern frontend engineer? #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #TechCareers #SoftwareEngineering #NextJS #Developers #CodingLife #CareerGrowth
To view or add a comment, sign in
-
-
🚨 You’re probably using Angular Signals WRONG… And it might be hurting your app performance 👇 Signals are powerful — but only if you use them correctly. Here are some common mistakes developers make 👇 --- ❌ **Replacing RxJS Everywhere** Signals are NOT a replacement for RxJS. ✔ Use Signals for state ✔ Use RxJS for async flows (API, streams) --- ❌ **Overusing effect()** Heavy logic inside effects = bad practice. ✔ Keep effects lightweight ✔ Use computed() for derived state --- ❌ **Not Using computed() Properly** Manual calculations = missed performance gains ✔ Use computed() ✔ Let Angular handle reactivity efficiently --- ❌ **Mixing Old Change Detection Thinking** Still stuck in Zone.js mindset? ✔ Shift to signal-based reactivity ✔ Keep your state clean and predictable --- 💡 **Key Takeaway:** Signals are not just a feature… they require a mindset shift. --- 💬 Which mistake have you made? Comment below — let’s discuss 👇 🔁 Follow for more practical Angular tips #Angular #AngularSignals #FrontendDevelopment #WebDevelopment #JavaScript #RxJS #SoftwareEngineering #CleanCode #FrontendDeveloper #TechTips #Programming #Developers #TechCommunity #LearnToCode #Hiring #OpenToWork #JobSearch #TechJobs #HiringDevelopers #FrontendJobs
To view or add a comment, sign in
-
-
🚀 Frontend Developer Roadmap If you want to become a Frontend Developer, start by building a strong foundation step by step: 1️⃣ HTML & CSS – Structure and styling of websites 2️⃣ JavaScript – Add interactivity and dynamic behavior 3️⃣ Responsive Design – Make websites work on all devices 4️⃣ Frontend Frameworks – React / Vue / Angular 5️⃣ Version Control – Git & GitHub 6️⃣ APIs – Fetch and display data from servers 7️⃣ Performance & Optimization – Faster and better user experience The key is simple: Keep learning. Keep building. Keep improving. 💻 💬 Which frontend skill are you currently learning? #frontenddeveloper #webdevelopment #javascript #coding #developers #tech
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