🚨 JavaScript Tricky Question #3 (Advanced) What will be the output? 🤯 Promise.resolve() .then(() => { console.log("A"); throw new Error("Error!"); }) .catch(() => { console.log("B"); }) .then(() => { console.log("C"); }); Think carefully (this is tricky) 💬 Comment your answer 👇 🔁 Follow for daily advanced JS questions #javascriptdeveloper #mernstackdeveloper #frontendinterview #javascriptquestions #webdevelopmenttips #learnjavascript #jsconcepts #asyncjavascript #developersindia #codinginterview #softwaredeveloperlife #nodejsdeveloper #reactdeveloper #techcareers
JavaScript Tricky Question: Promise Handling
More Relevant Posts
-
Node.js REPL is underrated. Need to test a function? Try a package? Debug a snippet? Just type: node Interactive JavaScript shell. No setup required. Simple tools. Powerful results. #NodeJS #REPL #DeveloperTools
To view or add a comment, sign in
-
🔥 JavaScript Devs — Why “Undefined” Causes So Many Real Bugs Hey devs 👋 One of the smallest values in JavaScript… Creates some of the biggest headaches 😅 👉 undefined often appears when: Missing API fields Wrong property names Unreturned functions Async race conditions 💥 Then suddenly: Cannot read property of undefined 💡 What helps: ✔ Optional chaining ?. ✔ Default values ?? ✔ Strong typing (TypeScript) ✔ Better API contracts ⚡ Senior insight: “Most runtime bugs start with assumptions.” Never assume data exists. What bug did undefined cause for you? #javascript #typescript #programmingtips #webdevelopment #frontenddeveloper #backenddeveloper #codingbestpractices #softwareengineering #jsbugs #cleanCode
To view or add a comment, sign in
-
-
Node.js Event Loop — One Concept Every Developer Should Know 🧠 Many developers get confused about this: Why does Promise run before setTimeout? Example 👇 console.log("Start"); setTimeout(() => console.log("Timeout"), 0); Promise.resolve().then(() => console.log("Promise")); console.log("End"); Output: Start → End → Promise → Timeout Why? Because JavaScript has 2 queues: ✔ Microtask Queue (Promises, async/await) ✔ Macrotask Queue (setTimeout, setInterval) Rule: 👉 Microtasks run before Macrotasks This is why Promise executes before setTimeout, even if timeout is 0ms. Understanding this helps in: ✔ Debugging async issues ✔ Writing better Node.js code ✔ Handling real-time applications 👇 Did this confuse you before learning event loop? #nodejs #javascript #eventloop #backenddeveloper #webdevelopment
To view or add a comment, sign in
-
JavaScript tricks I use all the time 👇 Save this 📌 ✅ Optional chaining user?.profile?.name ✅ Nullish coalescing const value = input ?? "default" ✅ Remove duplicates const unique = [...new Set(arr)] ✅ Short condition isLoggedIn && doSomething() ✅ Object destructuring const { name, age } = user 💡 Small JS tricks = cleaner + faster code What’s one JS trick you use daily? #JavaScript #TypeScript #Developers #WebDevelopment #Coding
To view or add a comment, sign in
-
-
𝗪𝗵𝘆 𝗬𝗼𝘂 𝗦𝗵𝗼𝘂𝗹𝗱 𝗦𝘁𝗼𝗽 𝗠𝘂𝘁𝗮𝘁𝗶𝗻𝗴 𝗔𝗿𝗿𝗮𝘆𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 (𝘚𝘦𝘳𝘪𝘰𝘶𝘴𝘭𝘺) 🧐 If you’ve been writing JavaScript for a while, you’ve probably spent hours debugging a feature that simply refused to update on the screen, only to realize the data had changed, but the app didn’t know it. #javascript #WebDevelopment #FullStackDeveloper
To view or add a comment, sign in
-
JavaScript: Mirror Distance Problem Day 5 👈 Goal: Find the mirror distance of a number — the absolute difference between the number and its reversed form. Approach: Reverse the given number using modulo (%) and division. Subtract the reversed number from the original. Take the absolute value to ensure a positive result. Example: Input: 123 Reversed: 321 Mirror Distance: |123 - 321| = 198 #JavaScript #TypeScript #DSA #CodingInterview #ProblemSolving #FrontendDevelopment #Developers #100DaysOfCode
To view or add a comment, sign in
-
-
JavaScript tricks I wish I knew earlier 🔥 These save me hours every week: 1. Optional chaining - stop writing null checks const city = user?.address?.city ?? 'Unknown' 2. Nullish assignment - set default only if null/undefined config.timeout ??= 3000 3. Array flat - flatten any nested array instantly const flat = nested.flat(Infinity) 4. Object.fromEntries - turn a Map or array back into an object const obj = Object.fromEntries(entries) 5. structuredClone - deep copy without JSON.parse hacks const copy = structuredClone(myObj) 6. at() method - negative index access const last = arr.at(-1) These work in modern Node.js and all major browsers. No libraries needed. Share this with a junior dev who needs it 🙌 Shoutout to JavaScript Mastery, w3schools.com for keeping docs and tutorials world-class. #JavaScript #WebDevelopment #CodingTips #ReactJS #NodeJS #FullStackDeveloper #100DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
New ES2023 JavaScript features are 🔥 toSorted(), toSpliced(), toReversed(), with(), findLast(), findLastIndex() help avoid mutation — super useful for React devs. Read here: https://lnkd.in/g9hkhk74 #javascript #react #webdev
To view or add a comment, sign in
-
#Day21 JavaScript just got a whole lot more interesting. Up until now, everything I wrote lived in the browser. Today I started working with Node.js and the fs module and for the first time, my code started talking to my computer directly. Three things clicked today: => Reading a file: "fs.readFile" opens a file sitting on your computer and prints its contents. That's it. No browser, no UI, just my code and my file system having a conversation. => Writing a file: "fs.writeFile" creates a brand new file and puts text inside it. If the file doesn't exist yet, Node creates it for you. One line of code does what used to feel like a whole process. => Appending to a file: "fs.appendFile" adds new content to an existing file without deleting what's already there. It runs after the file is created because in Node, async operations happen in sequence through callbacks. => process.on('uncaughtException'): Ending today with "process.on", this is a safety net. Instead of your program crashing with no explanation, it catches the error, tells you what went wrong, and shuts down cleanly. JavaScript isn't just a browser language. With Node.js, you can read files, write files, manage your system, and build backends all with the same language you already know. Same language. Bigger world. #NodeJS #JavaScript #M4ACELearningChallenge #BackendDevelopment #LearningToCode #WebDevelopment
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