O'Reilly logo

Head First JavaScript Programming by Elisabeth Robson, Eric T. Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Serious types

Types, Equality, Conversion and All That Jazz

image with no caption

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 way back about JavaScript? That it didn’t have the luxury of a silver-spoon, academic, peer-reviewed language definition? Well that’s true, but the 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 a lot of 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 from the official language of Webville? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required