🚀 Interview Question That Tests Your JavaScript Fundamentals Here’s a simple-looking question that often confuses even experienced developers: console.log([] == ![]); 👉 What will be the output? Most people expect false, but the answer is actually true 😲 💡 Let’s break it down: ![] → false (Because an empty array is truthy, so NOT makes it false) Now the expression becomes: [] == false During comparison: [] → converted to "" (empty string) false → converted to 0 Now: "" == 0 → true 🔥 Key Takeaway: JavaScript’s loose equality (==) does type coercion, which can lead to unexpected results. 💬 Have you faced similar tricky questions in interviews? Drop them below 👇 #react #javascript #interview #prep #prepration
Great question! It perfectly shows why relying on loose equality in JavaScript can be dangerous.
console.log(typeof NaN); Most people expect "NaN" or something similar, but the output is actually "number" 🤯 It shows how JavaScript treats NaN (Not a Number) as a special numeric value. These kinds of questions really test how well someone understands JavaScript fundamentals and edge cases, not just syntax. Great question! 🚀