Chapter 7. Types, Equality, Conversion, and all that jazz: Serious types

Image

It’s time to get serious about our types. One of the great things about JavaScript is you can get a long way without knowing a lot of details of the language. But to truly master the language, get that promotion, and get on to the things you really want to do in life, you have to rock at types. Remember what we said about JavaScript back in Chapter 1? That it didn’t have the luxury of a silver-spoon, academic, peer-reviewed language definition? Well, that’s true, but the lack of an academic life didn’t stop Steve Jobs and Bill Gates, and it didn’t stop JavaScript either. It does mean that JavaScript doesn’t have the...well, the most thought-out type system, and we’ll find a few idiosyncrasies along the way. But don’t worry, in this chapter we’re going to nail all that down, and soon you’ll be able to avoid all those embarrassing moments with types.

The truth is out there...

Now that you’ve had some experience working with JavaScript types—there’s your primitives with numbers, strings, and booleans, and there’s all the objects, some supplied by JavaScript (like the Math object), some supplied by the browser (like the document object), and some you’ve written yourself—aren’t you just basking in the glow of JavaScript’s simple, powerful, and consistent type system?

After all, what else would you expect ...

Get Head First JavaScript Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.