⚡ JavaScript Interview Question Day 1: What is the difference between: null vs undefined ? Quick explanation 👇 undefined ------------- • Variable declared but not assigned Example: let a; console.log(a) // undefined null ------ • Intentional absence of value Example: let user = null 💡 Tip: undefined → system assigned null → developer assigned #javascript #frontend #codinginterview #programming #interview #react #angular #performance #UI
JavaScript Interview: null vs undefined
More Relevant Posts
-
🚨 JavaScript Interview Question 🚨 99% of developers get this wrong on the first try 😵 What will be the output? 🤔 console.log("5" - 3); console.log("5" + 3); A) 2 and 8 B) 2 and "53" C) "2" and "53" D) NaN 👇 Drop your answer in the comments before checking! 💬 Be honest — did you get it right? 👇 Comment your answer (A/B/C/D) 🔁 Save this for interviews ❤️ Like if you learned something new 👥 Follow for daily JavaScript questions #javascript #webdevelopment #frontend #coding #interviewquestions #developers #100DaysOfCode #learncoding
To view or add a comment, sign in
-
JavaScript Interview Question I faced recently 💻 Convert this array "["a","1","b","2","c","3"]" into this object "{ a: 1, b: 2, c: 3 }" const arr = ["a","1","b","2","c","3"]; const obj = {}; for (let i = 0; i < arr.length; i += 2) { obj[arr[i]] = arr[i + 1]; } console.log(obj); // { a: "1", b: "2", c: "3" } Simple logic: The array has key–value pairs, so we loop through it two elements at a time. #JavaScript #FrontendDeveloper #CodingInterview
To view or add a comment, sign in
-
5 Advanced JavaScript Interview Questions Every Developer Should Know 🚀 JavaScript interviews often go beyond the basics. Understanding core concepts helps you write cleaner, scalable, and more efficient code. Here are 5 important JavaScript questions every developer should know: 1️⃣ What are Closures in JavaScript? A closure occurs when a function remembers variables from its outer scope, even after the outer function has finished executing. 2️⃣ What is the Event Loop? The Event Loop allows JavaScript to handle asynchronous operations (API calls, timers, promises) by managing the call stack and callback queue. 3️⃣ Difference between == and ===? • == → Compares values after type conversion • === → Strict comparison (value + type) 4️⃣ What is Hoisting? Hoisting means variable and function declarations are moved to the top of their scope during the compilation phase. 5️⃣ What are Promises? Promises are used to handle asynchronous operations and have three states: Pending → Fulfilled → Rejected 💡 Mastering these concepts helps developers build scalable and reliable applications. #JavaScript #WebDevelopment #Frontend #Programming #CodingInterview #Developers
To view or add a comment, sign in
-
💻 JavaScript Interview Question Write a function that takes a string input, and returns the first character that is not repeated anywhere in the string. For example, if given the input "stress", the function should return 't', since the letter t only occurs once in the string, and occurs first in the string. If a string contains only repeating characters, return an empty string (""); function firstNonRepeatingLetter(s) { let mySet = new Set(); //stress for(let c of s) { if(mySet.has(c.toLowerCase())) { mySet.delete(c.toLowerCase()); } else if(mySet.has(c.toUpperCase())) { mySet.delete(c.toUpperCase()); } else { mySet.add(c); } } const setAsArray = Array.from(mySet); if(setAsArray.length == 0) return (""); return (setAsArray[0]); } #javaScript #CodingInterview #WebDevelopment #Frontend #React
To view or add a comment, sign in
-
JavaScript Interview Question (Confusing but Important 🤯) What will be the output? console.log([] == []); console.log([] === []); console.log({} == {}); console.log({} === {}); 👉 Answer: All will be false Why? Arrays and objects in JavaScript are stored in memory by reference, not by value. Each [] or {} creates a new object with a different memory address, and JavaScript compares references — not structure or content. Same shape ≠ same reference 📌 This is one of the most common JavaScript interview traps. #JavaScript #InterviewQuestions #WebDevelopment #Frontend #Backend #CodingTips
To view or add a comment, sign in
-
Today’s Question: What is the difference between null and undefined? 🔍 This is one of the most common JavaScript interview questions. They might seem similar because they both represent "nothingness," but they have very different meanings in the engine. Take a look at the code in the screenshot below! 👇 ✅ The Simple Answer undefined: Means a variable has been declared but has not yet been assigned a value. It’s JavaScript’s default. null: Is an assignment value. It is used by developers to explicitly say a variable should be empty. 🔥 The Key Differences (Interview Breakdown): 1️⃣ Type Distinction 🧠 typeof undefined is "undefined". typeof null is "object". (Note: This is actually a long-standing bug in JavaScript, but it’s a favorite interview "gotcha"!) 2️⃣ Equality Comparison ⚖️ null == undefined is true (They are loosely equal in value). null === undefined is false (They are different types). 3️⃣ Mathematical Operations ➗ 1 + undefined results in NaN (Not a Number). 1 + null results in 1 (Because null is converted to 0 in math operations). ⚠️ Key Takeaway for Interviews: Think of undefined as a system-level missing value (uninitialized), and null as a program-level missing value (intentionally empty). 🎯 The One-Liner for Interviews: "undefined is the default value of an uninitialized variable, while null is an intentional assignment representing the absence of any object value." Stay tuned! I’ll be posting a new question every day at 6:00 PM. 🕕 Which one do you use more often to "clear" a variable? Let’s discuss in the comments! 👇 #JavaScript #WebDevelopment #InterviewPrep #Frontend #SoftwareEngineering #CleanCode #CodingChallenge #ProgrammingTips
To view or add a comment, sign in
-
-
𝗧𝗼𝗽 𝟱𝟬 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝘀 𝗳𝗼𝗿 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿𝘀 Preparing for a JavaScript interview? Here are some of the most commonly asked JavaScript questions every developer should know to crack frontend and full-stack interviews. These questions cover important concepts like: 🔹 JavaScript execution context 🔹 Scope, hoisting, and closures 🔹 "this" keyword and binding 🔹 Promises, async/await, and the event loop 🔹 Callbacks and asynchronous programming 🔹 Prototypes and prototypal inheritance 🔹 Event delegation and event bubbling 🔹 Map, filter, reduce, and higher-order functions 🔹 Debouncing vs throttling 🔹 Deep copy vs shallow copy 🔹 Memory management and garbage collection 🔹 ES6 features like destructuring, spread, rest, and modules Mastering these concepts will help you perform confidently in frontend, backend, and full-stack developer interviews. Follow for more coding and interview preparation content. #JavaScript #JavaScriptInterview #CodingInterview #FrontendDevelopment #WebDevelopment #FullStackDeveloper #SoftwareEngineer #TechInterview #LearnJavaScript #Developers
To view or add a comment, sign in
-
#JavaScript Interview Series: Do you REALLY know how Hoisting works? Ever wondered why you can call a function before it's defined, but let and const throw an error? That's Hoisting in action! 🧐 In JavaScript, variable and function declarations are moved to the top of their scope during the compilation phase. But there's a catch... ✅ Functions: Fully hoisted. You can call them anytime. ✅ var: Hoisted but initialized as undefined. ❌ let & const: Hoisted but in the "Temporal Dead Zone" (TDZ). You can't touch them until the line of declaration. Check out the example below: console.log(a); // undefined var a = 5; greet(); // "Hello!" function greet() { console.log("Hello!"); } // console.log(b); // ReferenceError! let b = 10; Mastering these core concepts is the difference between a Junior and a Senior developer. 💻✨ Ready to ace your next JS interview? I've curated a list of the most important JavaScript questions with deep dives and Hinglish explanations! 👇 🔗 Read more here: https://lnkd.in/ghMhTcws #JavaScript #WebDevelopment #InterviewPrep #Coding #Programming #HashWebix #Frontend #ReactJS #NodeJS #TechInsights
To view or add a comment, sign in
-
-
𝗦𝘁𝗼𝗽 𝘀𝗰𝗿𝗼𝗹𝗹𝗶𝗻𝗴! 🛑 Do you know the difference between 𝗻𝘂𝗹𝗹 and 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱 in JavaScript? Many interviewers love asking this! Let’s keep it simple. Understanding null and undefined can save you from silly mistakes in code and help you nail JavaScript interviews. 1️⃣ 𝗨𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱 ========== • A variable is declared but not assigned → it’s undefined. • Automatically given by JavaScript. • Type: undefined 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝘭𝘦𝘵 𝘢𝘨𝘦; 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨(𝘢𝘨𝘦); // 𝘶𝘯𝘥𝘦𝘧𝘪𝘯𝘦𝘥 --------------------------------------------- 2️⃣ 𝗡𝘂𝗹𝗹 ======== • When a variable is intentionally empty, we assign null. • Manually assigned by the developer. • Type: object 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝘭𝘦𝘵 𝘶𝘴𝘦𝘳𝘚𝘦𝘭𝘦𝘤𝘵𝘪𝘰𝘯 = 𝘯𝘶𝘭𝘭; 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨(𝘶𝘴𝘦𝘳𝘚𝘦𝘭𝘦𝘤𝘵𝘪𝘰𝘯); // 𝘯𝘶𝘭𝘭 ---------------------------------------------- 3️⃣ Interview Tip: ============= • undefined == null → true • undefined === null → false ✅ 💡 Always use === to avoid unexpected results in your code. --------------------------------------------- 𝗪𝗮𝘀 𝘁𝗵𝗶𝘀 𝗵𝗲𝗹𝗽𝗳𝘂𝗹? 💬 • Yes → Repost to share with friends • No → Comment below what you want me to explain next! Follow Muhammad Muzzamal for more simple and practical JavaScript tips every day. #JavaScript #CodingInterview #WebDevelopment #Frontend #100DaysOfCode #ProgrammingTips
To view or add a comment, sign in
-
-
📝 JavaScript Interview Essentials: Closures & Debouncing Explained! 🚀 Ever feel like you understand a concept until an interviewer asks you to explain it? You’re not alone. Closures and Debouncing are two of the most "asked yet misunderstood" topics in JS. Here’s the "TL;DR" (Too Long; Didn't Read) version: 1️⃣ Closures: The "Function with a Memory" 🧠 A closure happens when a function "remembers" the variables from its outer scope, even after that outer function has finished running. Real-world use: Creating private variables or stateful functions (like a counter). Interview Tip: If they ask why we use them, mention Data Encapsulation. 2️⃣ Debouncing: The "Patience Filter" ⏳ Debouncing is a technique to limit how often a function gets called. It waits for a specific amount of "silence" before executing. Real-world use: Search bars! You don't want to hit the API on every single keystroke; you wait until the user stops typing for 300ms. Interview Tip: Mention it’s crucial for Performance Optimization and reducing server load. Which one did you find harder to learn when you started? Let’s discuss in the comments! 👇 #JavaScript #WebDevelopment #Frontend #CodingTips #SoftwareEngineering #Programming #ReactJS #CareerGrowth #TechInterview #WebDev #CleanCode
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