Primitives Types
Man, I still remember the first time I did 0.1 + 0.2 in the console and got 0.30000000000000004.
0.1 + 0.2
// 0.30000000000000004.Thought my laptop was drunk. Turns out it’s just JavaScript being JavaScript. 😂
That floating-point nonsense? It’s because of how numbers work under the hood — all tied to these 7 primitive types JS actually has:
string, number, bigint, boolean, undefined, null, symbol.
Get Al-Hussein Abubakar’s stories in your inbox
Join Medium for free to get updates from this writer.
Primitives are the raw building blocks. They’re immutable (you don’t change “hello”, you make a new string), compared by value, not reference. Super simple, but they trip everyone up at some point.
Like why typeof null is “object” — yeah, that’s a legit 1995 bug they never fixed because too much code would break. Or how “hello”.toUpperCase() even works when strings aren’t objects (autoboxing magic, basically JS wraps it for a second then throws the wrapper away).
I just dropped a full breakdown on the blog — nothing fancy, just straight explanations + code snippets for the gotchas that still catch me sometimes. Especially useful if you’re debugging weird equality bugs or wondering when to reach for BigInt instead of Number.
Any primitive quirk that made you go “wait, what?!” when you first saw it? Hit me in the comments — I live for these war stories. 😅
https://blog.al-husayn.dev/blog/primitive-types








