💡 Interview Question: Understanding Data Types in JavaScript Recently came across an interesting question that tests your fundamental 👇 let a = ''; let b = false; let c = 0; let d = null; let e; let f = {}; let g = []; if (!a) console.log('1') // similarly check for b, c, d, e, f, g 👉 Question: What will be printed in the console for each variable? 🧠 Concept Tested: Truthy vs Falsy values in JavaScript 📌 Falsy values in JS: '' (empty string) false 0 null undefined NaN 📌 Truthy values: {} (empty object) [] (empty array) ✅ Output: 1 2 3 4 5 (Only for a, b, c, d, e → because they are falsy) 🚫 Nothing will be printed for: f = {} g = [] (because they are truthy) 🎯 Key Takeaway: Even empty objects and arrays are considered truthy in JavaScript — a common interview trap! #JavaScript #FrontendDevelopment #WebDevelopment #CodingInterview #InterviewQuestions #Programming #Developers #TechTips #LearnToCode
JavaScript Truthy vs Falsy Values Interview Question
More Relevant Posts
-
🚀🔥 Mastering JavaScript String Methods & Real-Time Problems 🔥🚀 🚀Today I focused on strengthening my String fundamentals + problem-solving skills 💻🧠 ✨ What I Practiced: 🔹 Clean user input by removing unwanted spaces 🔹 Case-insensitive comparisons (real login scenarios) 🔹 Searching words inside strings 🔹 Extracting specific parts of strings (like usernames, substrings) 🔹 Converting data types (string ↔ number) 🔹 Working with arrays from strings 💡 Real-Time Use Cases I Solved: ✅ Email username extraction ✅ File type validation (.html check) ✅ Password masking using symbols ✅ Replacing spaces for URL-friendly strings ✅ Checking word existence in sentences 🧠 Logic-Based Problems Covered: 🔸 Reverse a string (without built-in methods) 🔸 Check palindrome 🔸 Count vowels in a string 🔸 Find frequency of characters 🔸 First repeating & non-repeating character 🔸 Remove duplicate characters 🔸 Check anagrams 🔸 String compression (aaabbc → a3b2c1) 🔸 Reverse case transformation (hELLO wORLD) 🔥 Key Learnings: ✔️ Strings are immutable (operations return new values) ✔️ Combining multiple methods is powerful ✔️ Logic building is more important than memorizing methods ✔️ Writing generic solutions is crucial for interviews #JavaScript #WebDevelopment #FrontendDeveloper #CodingJourney #ProblemSolving #DSA #LearningInPublic #CareerGrowth #TechJourney
To view or add a comment, sign in
-
JavaScript Array Methods, Simplified Want to master arrays in JavaScript but are overwhelmed by all the methods? 👉 JavaScript Interview Pack 🔗 https://lnkd.in/ggHpPYWf Here’s a quick breakdown of essential array methods : 1. Add or Remove Items Use .push(), .pop(), .shift(), and .unshift() to modify arrays by adding/removing elements at the beginning or end. 2. Transform and Extract Data Methods like .map(), .filter(), .slice() help reshape arrays, filter elements, or extract portions without changing the original. 3. Search and Identify Values With .indexOf(), .find(), .includes(), and similar methods, you can locate items or check for their presence efficiently. 4. Combine, Loop & Display .forEach(), .concat(), .join() and .splice() help you combine arrays, iterate through them, or update their content. 👉 JavaScript Interview Pack 🔗 https://lnkd.in/ggHpPYWf 5. Evaluate & Organize Use .sort(), .reverse(), .every(), .some(), and .reduce() to evaluate, sort, or summarize your array in one line. Check the post for more details -- Credit: Shubham Soni Learn JavaScript 💫 W3Schools.com JavaScript Mastery freeCodeCamp Big Thanks 🫶: LinkedIn 👉 JavaScript Interview Pack 🔗 https://lnkd.in/ggHpPYWf #Linkedin #LinkedinCommunity #Connections #viral #fyp #w3schools #expressjs #javascript #frontend #backend #developers #css #reactjs #nextjs #roadmap #webdevelopment #mern #mean #angular #nodejs #expressjs #postgresql #sql #guide #useful #notes
To view or add a comment, sign in
-
-
📘 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐌𝐨𝐝𝐮𝐥𝐞 (𝐁𝐚𝐬𝐢𝐜) -> Save this checklist, I hope it will be of great use in your next interview revision! 👇 𝐒𝐞𝐜𝐭𝐢𝐨𝐧 2: 𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 11. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐮𝐧𝐝𝐞𝐟𝐢𝐧𝐞𝐝? -> JavaScript's default value is when nothing is assigned. This is a default behavior of JavaScript. If you have declared a variable (var age;) but have not given a value, JavaScript will automatically call it undefined. 12. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐍𝐚𝐍? -> Not a Number — invalid number result. This comes when you do something wrong while doing math. Example: If you multiply your name by 10 ("Sohan" * 10), JavaScript will say—brother, this is not a number, so the output will be NaN. 13. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐧𝐮𝐥𝐥? -> Intentionally assigning an empty value. You do this intentionally. When you want a variable to be empty now, and later the data will come, then you set age = null; yourself. 14. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐜𝐨𝐧𝐜𝐚𝐭𝐞𝐧𝐚𝐭𝐢𝐨𝐧? -> Adding two strings or concatenating two texts. For example: "Hello " + "World". 15. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐈𝐧𝐟𝐢𝐧𝐢𝐭𝐲? -> When a number is divided by 0. 50/0 result infinity. 16.𝐇𝐨𝐰 𝐭𝐨 𝐚𝐬𝐬𝐢𝐠𝐧 𝐝𝐚𝐭𝐚 𝐭𝐨 𝐚 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞? / 𝐇𝐨𝐰 𝐭𝐨 𝐚𝐬𝐬𝐢𝐠𝐧 𝐚 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞 𝐝𝐚𝐭𝐚? -> let x; x = 10; 17. 𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞 𝐢𝐬 𝐩𝐫𝐢𝐦𝐢𝐭𝐢𝐯𝐞 𝐨𝐫 𝐧𝐨𝐧-𝐩𝐫𝐢𝐦𝐢𝐭𝐢𝐯𝐞? -> Primitive (stores single data of single value) #DotNet #AspNetCore #MVC #FullStack #SoftwareEngineering #ProgrammingTips #DeveloperLife #LearnToCode #JavaScript #JS #JavaScriptTips #JSLearning #FrontendDevelopment #WebDevelopment #CodingTips #CodeManagement #DevTools
To view or add a comment, sign in
-
-
🚀 JavaScript Last-Minute Cheat Sheet — Perfect Before Interviews & Coding Rounds 🔥 Variables & Scope • "let" & "const" over "var" • Block scope matters • Avoid global variables ⚡ Functions • Arrow functions → shorter syntax • Default parameters save time • Closures = function + lexical scope 🧠 Async JavaScript • Callbacks → Promises → "async/await" • Use "try...catch" for error handling • "Promise.all()" for parallel execution 📦 Arrays & Objects • "map()", "filter()", "reduce()" = must know • Spread "..." & Destructuring simplify code • Optional chaining "?." prevents crashes 🎯 DOM & Events • "querySelector()" is your best friend • Event delegation improves performance • Debounce & throttle for optimization 💡 Pro Tip Understand concepts, not just syntax. Clean code + problem-solving mindset = real JavaScript mastery. Follow Rahul Choudhary for more. Cr - Respected Owner Learn more From w3schools.com JavaScript Mastery ✨ #JavaScript #WebDevelopment #FrontendDeveloper #CodingInterview #100DaysOfCode #javascript #html #programming #coding #css #java #python #programmer #developer #webdevelopment #webdeveloper #coder #code #php #webdesign #codinglife #softwaredeveloper #computerscience #software #reactjs #technology #frontend #development #tech #linux #javascriptdeveloper #frontenddeveloper #programmers #softwareengineer #web
To view or add a comment, sign in
-
🚨 Stop scrolling—quick question for developers... Ever blanked out on JavaScript syntax right when you needed it most? You’re not alone. One minute you’re confident, the next you’re stuck thinking: “Is it ".slice()" or ".substring()"?” “How does "try...catch" go again?” That pressure is real—especially during interviews or deadlines. So I created a JavaScript Last-Minute Cheatsheet to make things simple. 💡 Inside, you’ll get: ✔️ Core Basics – Data types, operators, conditionals ✔️ Must-Know Methods – String, Array & Math shortcuts ✔️ DOM Essentials – Select, create & update elements easily ✔️ Advanced Concepts – Promises, async/await & closures (made simple) Whether you're revising before an interview or just tired of Googling basics again and again—this is for you. 📩 Want the full PDF? 1️⃣ Like this post 2️⃣ Comment "JS" 3️⃣ Follow for more daily dev content Let’s code smarter, not harder 💻 #JavaScript #WebDevelopment #CodingTips #SoftwareEngineering #LearnToCode #Developers #Programming #TechCommunity
To view or add a comment, sign in
-
Javascript: typeof operator ⚡ JavaScript has a tiny operator that reveals BIG truths. It’s called typeof. If you’re new to JavaScript, this operator helps you understand what type of data you’re working with. That’s extremely helpful when debugging or writing safer code. Here’s why developers love using typeof: • It tells you the data type of a variable • It helps debug unexpected values • It works with numbers, strings, booleans, objects, functions, and more • It prevents logic errors in conditions Example: typeof "Hello" // "string" typeof 42 // "number" typeof true // "boolean" typeof undefined // "undefined" typeof {} // "object" 💡 Simple rule: When you're unsure about a value → use typeof. Small operator. Huge debugging power. #JavaScript #WebDevelopment #FrontendDevelopment #LearnToCode #ProgrammingBasics #JavaScriptTips #CodingForBeginners #SoftwareDevelopment #DeveloperCommunity #TechLearning
To view or add a comment, sign in
-
-
💡 JavaScript Essentials for Every Developer: Map vs Set While preparing for DSA rounds and real-world problem solving, I revisited two powerful JavaScript data structures — Set and Map. Sharing a quick breakdown 👇 🔹 Set Stores only unique values Automatically removes duplicates Useful for: Removing duplicates from arrays Checking existence efficiently (O(1)) Example: const unique = [...new Set([1,2,2,3])]; // [1,2,3] 🔹 Map Stores key-value pairs Keys can be of any type Maintains insertion order Useful for: Fast lookups Counting frequency Problems like Two Sum Example: const map = new Map(); map.set("a", 1); map.set("b", 2); ⚔️ Set vs Map Set → Only values (no duplicates) Map → Key → Value mapping 🚀 Where I see them used most: Set → Sliding window problems, uniqueness checks Map → Caching, indexing, and optimization problems 🎯 Takeaway: Understanding when to use Map vs Set can significantly improve both performance and code clarity. If you're preparing for interviews — don’t skip these! #JavaScript #FrontendDevelopment #DSA #React #WebDevelopment #CodingInterview
To view or add a comment, sign in
-
JavaScript Array Methods you CAN’T ignore as a developer 🚀 If you’re still looping everything manually… you’re doing it wrong. Here are must-know array methods every dev should master: 🔥 filter() → Get matching data 🔥 map() → Transform data 🔥 find() → First match 🔥 some() → At least one condition 🔥 every() → All conditions must pass 🔥 includes() → Check existence 🔥 findIndex() → Get index 🔥 push()/pop() → Modify array 💡 Pro Tip: Use map() + filter() heavily in React for clean & scalable code. Master these = cleaner code + better interview performance 💯 💾 Save this for later 💬 Which one do you use the most? #javascript #webdevelopment #reactjs #codingtips #frontend #backend #programming
To view or add a comment, sign in
-
-
"Would you be able to answer these frontend questions under pressure? 🧠 I was recently tested on these exact concepts. Some were easy, some were tricky, but all of them are essential. How many of these can you solve? 👇" 1️⃣ How does hoisting behave with var, let, and const in JavaScript? 2️⃣ What exactly is the JavaScript Event Loop? 3️⃣ How does JavaScript handle asynchronous tasks internally? 4️⃣ What is the window object in JavaScript? 5️⃣ What is the difference between a class and a constructor? 6️⃣ What are Event Bubbling and Event Capturing? Which one is false by default? 7️⃣ What is the Browser Object Model (BOM)? 8️⃣ What is an Immediately Invoked Function Expression (IIFE)? 9️⃣ Why is JavaScript called a scripting language? 🔟 What is the difference between formal parameters and actual parameters? 💡 If you're learning JavaScript or preparing for interviews, try answering these in the comments! #javascript #webdevelopment #frontend #coding #programming #developers #learning #coding #learning #developers
To view or add a comment, sign in
-
🚀 JavaScript Last-Minute Cheat Sheet — Perfect Before Interviews & Coding Rounds 🔥 Variables & Scope • "let" & "const" over "var" • Block scope matters • Avoid global variables ⚡ Functions • Arrow functions → shorter syntax • Default parameters save time • Closures = function + lexical scope 🧠 Async JavaScript • Callbacks → Promises → "async/await" • Use "try...catch" for error handling • "Promise.all()" for parallel execution 📦 Arrays & Objects • "map()", "filter()", "reduce()" = must know • Spread "..." & Destructuring simplify code • Optional chaining "?." prevents crashes 🎯 DOM & Events • "querySelector()" is your best friend • Event delegation improves performance • Debounce & throttle for optimization 💡 Pro Tip Understand concepts, not just syntax. Clean code + problem-solving mindset = real JavaScript mastery. Follow Lakhan Soni for more. Cr - Respected Owner Learn more From w3schools.com JavaScript Mastery✨ #WebDevelopment #FrontendDeveloper #CodingInterview #100DaysOfCode #javascript #html #programming #coding #css #java #python #programmer #developer #webdevelopment hashtag #webdeveloper hashtag #coder hashtag #code hashtag #php hashtag #webdesign #softwaredeveloper #computerscience #software #reactjs #technology #frontend #development #tech #linux #javascriptdeveloper #frontenddeveloper #programmers #softwareengineer #web
To view or add a comment, sign in
Explore related topics
- Backend Developer Interview Questions for IT Companies
- Common Coding Interview Mistakes to Avoid
- Advanced React Interview Questions for Developers
- Mock Interviews for Coding Tests
- Common Data Structure Questions
- How to Use Arrays in Software Development
- Understanding Data Team Interview Realities
- Amazon SDE1 Coding Interview Preparation for Freshers
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