⚡10 JavaScript Concepts You Thought You Knew (But Didn’t)
2 mins read

⚡10 JavaScript Concepts You Thought You Knew (But Didn’t)


JavaScript looks simple — until it isn’t.
Even if you’ve been writing JS for years, there are small things that quietly behave in unexpected ways.

Here are 10 JavaScript concepts that often fool even experienced developers 👇



🧩 1. == vs ===

== does type coercion, while === doesn’t.
But did you know these?

💡 Lesson: always use === unless you enjoy debugging existential crises.




🌀 2. this isn’t what you think

this depends on how a function is called, not where it’s written.

💡 Lesson: use arrow functions or .bind() when passing methods around.




🔄 3. Closures aren’t just for interviews

Closures happen anytime a function “remembers” variables from its parent scope.

💡 Closures power things like React hooks, private variables, and debounce functions.




🕳️ 4. var is secretly a time traveler

var is function-scoped, not block-scoped — and gets hoisted to the top.

💡 Use let and const — they save you from strange timeline bugs.




⚙️ 5. Hoisting isn’t just for variables

Functions get hoisted too — but only declarations, not expressions.




🧠 6. The Event Loop isn’t magic

It’s just a queue system.

setTimeout(fn, 0)
Enter fullscreen mode

Exit fullscreen mode

doesn’t run immediately — it goes to the queue.

💡 JS runs synchronously first, async tasks wait their turn.




⚡ 7. Objects compare by reference

Even if they look identical:

💡 Two separate objects never share the same reference.




🧩 8. typeof null is… “object”?!

Yes. It’s a 25-year-old bug that’s now part of the spec.

💡 Don’t trust typeof blindly. Use strict checks when needed.




🔍 9. Destructuring skips undefined

💡 Always give fallback values if you’re not sure about array/object shapes.




🚀 10. NaN isn’t equal to itself

💡 It’s the only value in JS that’s not equal to itself.




🎯 Final Thoughts

JavaScript keeps you humble — just when you think you’ve mastered it, it throws something weird your way.
But that’s also what makes it fun.

Keep experimenting, stay curious, and you’ll never stop leveling up as a developer.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *