Don't let curly braces trick you in JavaScript! 🚀 I came across this tricky interview question today and it’s a perfect reminder of how small syntax details change everything. Many developers would glance at this and expect [2, 4, 6]. But if you run this code, the result is actually [undefined, undefined, undefined]. Why? In JavaScript arrow functions, if you use curly braces { }, you must use an explicit return keyword. Without it, the function returns undefined by default for every element in the map. Fix it by: 1. Adding the return keyword inside the block. 2. Or, removing the curly braces for an implicit return: nums.map(num => num * 2). Small details make big differences in debugging! 💻 Feel free to reach me out for any career mentoring. Naveen .G.R | CareerByteCode #javascript #mernstack #webdevelopment #codingtips #learningjourney #60daychallenge
JavaScript Curly Braces Gotcha: Explicit Return Required
More Relevant Posts
-
Arrays Are More Powerful Than You Think Arrays are a core part of JavaScript development, but many developers only use a small portion of what arrays can actually do. I’ve shared a PDF guide — JS Array Masterclass — where I break down: ⚡ Key JavaScript Array concepts ⚡ Useful built-in array methods ⚡ Practical examples for real-world coding ⚡ Tips to write better and more efficient JavaScript This resource is especially helpful for: 👨💻 Beginner developers learning JavaScript 👨💻 Frontend developers improving fundamentals 👨💻 Anyone preparing for coding interviews 📄 Take a look at the PDF and share your thoughts! #JavaScript #WebDevelopment #FrontendDev #ProgrammingCommunity #LearnProgramming #CodingTips #TechEducation #LearnJavascript #js #MERN #LearnMERN #React #Array #Arrays #adityathakor #aditya #adityaThakor
To view or add a comment, sign in
-
🚀 JavaScript Timers & Intervals — Explained Simply! Struggling to understand setTimeout() and setInterval()? Here’s a beginner-friendly visual that makes it easy 👇 ⏰ Key Concepts: setTimeout() → Runs once after a delay setInterval() → Runs again & again clearInterval() → Stops the timer These are super useful for: ✅ Countdown timers ✅ Notifications ✅ Digital clocks ✅ Auto-refresh features If you're learning JavaScript or preparing for interviews, this is a must-know topic 💡 💬 Comment “JS” if you want more simple dev content like this! #JavaScript #WebDevelopment #FrontendDeveloper #FullStackDeveloper #CodingTips #LearnToCode #Programming #DeveloperCommunity #TechLearning #100DaysOfCode #JavaScriptBasics #CodingLife #SoftwareDeveloper #CareerInTech #WebDev
To view or add a comment, sign in
-
-
𝗪𝗵𝘆 𝗱𝗼𝗲𝘀 𝘀𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁(..., 𝟬) 𝗿𝘂𝗻 𝗟𝗔𝗦𝗧? 😳 I used to think 0ms means it runs immediately. It doesn’t. And this confusion is exactly why so many developers struggle with asynchronous JavaScript. Here’s a quick challenge 👇 𝗰𝗼𝗻𝘀𝗼𝗹𝗲.𝗹𝗼𝗴("𝗦𝘁𝗮𝗿𝘁"); 𝘀𝗲𝘁𝗧𝗶𝗺𝗲𝗼𝘂𝘁(() => 𝗰𝗼𝗻𝘀𝗼𝗹𝗲.𝗹𝗼𝗴("𝗧𝗶𝗺𝗲𝗼𝘂𝘁"), 𝟬); 𝗣𝗿𝗼𝗺𝗶𝘀𝗲.𝗿𝗲𝘀𝗼𝗹𝘃𝗲().𝘁𝗵𝗲𝗻(() => 𝗰𝗼𝗻𝘀𝗼𝗹𝗲.𝗹𝗼𝗴("𝗣𝗿𝗼𝗺𝗶𝘀𝗲")); 𝗰𝗼𝗻𝘀𝗼𝗹𝗲.𝗹𝗼𝗴("𝗘𝗻𝗱"); What’s the output? Most developers get this wrong. Understanding this properly means you finally understand: ✅ Event Loop ✅ Call Stack ✅ Microtasks vs Macrotasks ✅ Promises If you’re learning JavaScript or preparing for interviews, this will genuinely help you. 🎥 Video link is in the comments. Comment “EVENT LOOP” if you know the correct output 👇 I’ll reply to everyone. #JavaScript #AsyncJavaScript #EventLoop #FrontendDeveloper #WebDevelopment #Coding #JSInterview
To view or add a comment, sign in
-
Most students spend 2–3 years “learning JavaScript” without a clear structure. This roadmap compresses it in just few weeks. Core → Advanced → Projects → Interview Ready. Three 90 Challenge will end tomorrow, start before it's too late 👉 https://lnkd.in/g8MtHaQ7 . . . #GeeksforGeeks #Javascript #Three90challenge
To view or add a comment, sign in
-
-
Still confused about var, let, and const in JavaScript? I created a clear and beginner-friendly PDF explaining Modern JavaScript Variables, including scope, hoisting, and real-world best practices. Mastering these fundamentals is crucial for: 🔹 Writing bug-free code 🔹 Passing technical interviews 🔹 Becoming a better frontend developer Download, read, and level up your JavaScript skills today! #JavaScript #SoftwareEngineering #WebDevelopment #TechCommunity #Programming #FrontendDevelopment #DeveloperJourney #aditya_thakor
To view or add a comment, sign in
-
💡 Currying in JavaScript 🧠 What is Currying? It is a technique where a function with multiple arguments is converted into a chain of functions, each taking one argument. ⚡ Why use it? ✔️ Better reusability ✔️ Cleaner & readable code ✔️ Helps in functional programming 🧠 Think Like This Instead of calling all arguments at once, you pass them one by one. 🎯 Interview One-Liner Currying transforms a function into multiple nested functions. 📌 Used In Functional programming Partial application Reusable utility functions #JavaScript #Angular #Currying #FunctionalProgramming #FrontendDevelopment #InterviewTips
To view or add a comment, sign in
-
JavaScript: Callbacks vs Promises (Beginner-Friendly PDF) If you’re learning JavaScript or preparing for frontend interviews, understanding asynchronous programming is non-negotiable. In this short PDF, I’ve explained: -- Why async code is needed -- What callbacks are (and why callback hell happens) -- What promises are (and how they improve readability) -- Clear comparison: Callbacks vs Promises -- Syntax + error handling differences This will help you write cleaner async code and avoid common mistakes in real projects and interviews. 👉 Download the PDF & save it for quick revision 👉 Share with your friends who are learning JavaScript Powered by Mohit Decodes #javascript #mohitdecodes #webdevelopment #frontenddeveloper
To view or add a comment, sign in
-
💡 JavaScript Interview Question Today in my mock interview I was asked: ❓ What is a Debugger in JavaScript? A debugger is used to identify and fix errors (bugs) in the code. JavaScript provides a debugger statement that pauses the execution of code when browser developer tools are open. This helps developers inspect variables and understand how the code is running step by step. Example: let a = 10; let b = 20; debugger; let sum = a + b; console.log(sum); When the program reaches the debugger line, the browser pauses execution so we can check the values of variables. 🚀 Debugging is an important skill for every developer because it helps us understand how our code works and fix issues quickly. #JavaScript #FrontendDeveloper #WebDevelopment #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
Mastering Numbers & Math in JavaScript I’ve shared a PDF guide explaining how numbers actually work in JavaScript. Many developers use numbers every day but don’t realize: ⚡ JavaScript uses 64-bit floating point numbers ⚡ Large integers require BigInt ⚡ Some calculations can lead to precision issues ⚡ The Math object provides powerful utilities This guide simplifies these concepts with clear explanations so developers can better understand numeric operations in JavaScript. If you're improving your JavaScript fundamentals, this resource might help. 📄 Check out the PDF and let me know what you think. #JavaScriptDeveloper #FrontendDevelopment #WebDev #CodingLife #ProgrammingTips #SoftwareDevelopment #TechLearning #MERN #MERNStack #Javascript #Javascript_Learning #js #node #Aditya_Thakor #aditya #adityathakor
To view or add a comment, sign in
-
⚠️ JavaScript looks simple… until loops start lying to you. Same code. Same logic. But "var" prints 4 4 4 instead of 1 2 3 🤯 It’s not a bug. It’s how JavaScript actually works. In Part 9 of the JavaScript Confusion Series, I break down the real reason behind "var" vs "let" inside loops — with a mental model you won’t forget. 👉 Read it here: https://lnkd.in/gvwZqJCe 💬 Comment LOOP if this ever confused you. 🔖 Save for interviews. 🔁 Share with a developer who still trusts "var". #javascript #webdevelopment #frontend #programming #learnjavascript
To view or add a comment, sign in
-
More from this author
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