Appendix A. Leftovers: The top ten topics (we didn’t cover)
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> ...
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.