I was once teaching a class on JavaScript to a group of C# developers when someone asked a very logical question, “Are JavaScript Types all derived from Object?” I loved teaching this particular group because they were actively engaged in the material. So many times, when I teach, the students simply absorb what I say, but they don’t interact with it. They never ask the question, “What are the implications of what is being said.” My initial instinct was to say ‘no’ based on my experience with the language. But then as I thought about it later, I thought, “But when I use the debugger on what seems to be a primitive, don’t I see it as an object?” And as it turns out, my instinct was right. Not everything in JavaScript is an object. Although there is quite a bit that you wouldn’t think was an object that is.
Now that we’ve covered JavaScript Objects and JavaScript Object Fields, it is time to move on to the specifics of JavaScript types.
So, why is it, when I look at some primitive values, I see them as objects? And which types are objects and which are primitives?