Skip to Main Content
Head First JavaScript Programming, 2nd Edition
book

Head First JavaScript Programming, 2nd Edition

by Eric Freeman, Elisabeth Robson
August 2024
Beginner content levelBeginner
662 pages
17h 50m
English
O'Reilly Media, Inc.
Content preview from Head First JavaScript Programming, 2nd Edition

Appendix A. Leftovers: The top ten topics (we didn’t cover)

Image

We’ve covered a lot of ground, and you’re almost finished with this book. We’ll miss you, but before we let you go, we wouldn’t feel right about sending you out into the world without a little more preparation. We can’t possibly fit everything you’ll need to know into this relatively small chapter. Actually, we did originally include everything you need to know about JavaScript programming (not already covered by the other chapters), by reducing the type point size to .00004. It all fit, but nobody could read it. So we threw most of it away, and kept the best bits for this “top ten” Appendix A.

This really is the end of the book. Except for the index, of course (a must-read!).

#1 Modules

We talked a lot about scope in this book. One JavaScript language feature related to scope that we didn’t mention is modules. A module is another way to limit the visibility of your code, at the file level.

Using modules is easy. You just need to learn two new keywords and a few simple rules. Let’s say you have a file, “taxi.js”, containing a class Taxi and a function createFleet that creates a fleet of taxis. You also have a web page that creates a list of taxis for users who are interested in hailing a taxi.

You could link from your HTML to your “taxi.js” file using a regular script link, like this:

<script src="./taxi.js"></script> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First JavaScript Programming

Head First JavaScript Programming

Eric T. Freeman, Elisabeth Robson
Head First HTML and CSS, 2nd Edition

Head First HTML and CSS, 2nd Edition

Elisabeth Robson, Eric Freeman

Publisher Resources

ISBN: 9781098147938Errata Page