Or, What it really means when people say “Everything in JavaScript is an object”

When you begin programming with JavaScript you might run across books, tutorials, and people who say “Everything in JavaScript is an object.” While it’s not 100% true (not everything is an object), it is mostly true. And sometimes this can be a bit surprising.

For instance, to most people functions and objects look and act completely different. And in many languages, functions and objects are completely different. However, in JavaScript, a function is an object. This can take a bit of concentrated attention to get your head around, but it’s an important concept because it’s the secret behind another big topic in JavaScript: functions as first class values.

And what about values like numbers, booleans and strings? One of the first things you learn when you pick up a book or tutorial on JavaScript is that these kinds of values are “primitive” values; in other words, they’re definitely not objects. And yet, you’ll quickly find out that in JavaScript, sometimes they are objects!

So bend your mind a bit, and immerse yourself in the world of objects to learn how, in JavaScript, (almost) everything is an object in this installment of Head First JavaScript Programming Teasers.

Previous Head First JavaScript Programming Teasers Episodes

Don't miss out!!

Don't miss out on brain-friendly WickedlySmart updates early access to books and general cool stuff! Just give us your email and we'll send you something about once a week. 

You have Successfully Subscribed!