JavaScript for Absolute Beginners - McNavage, Terry (Apress, 2012)
In the 2005 film adaptation of The Hitchhiker’s Guide to the Galaxy by Douglas Adams, aliens demolish the earth to make way for a hyperspace expressway. Our demise could have been averted insofar as the demolition proposal had been on file at local planning offices worldwide for some time. However, no one complained during the public comment period. Like construction proposals, no one ever bothers to read the preface to a programming book. Typically, that’s mostly harmless, but not for this book. Though you won’t be vaporized into star dust for jumping to Chapter 1 or later, you’ll be befuddled for not having downloaded and familiarized yourself with Firebug, our tool for learning JavaScript. JavaScript is a beginner-friendly programming language available in browsers such as Internet Explorer, Firefox, Safari, Opera, and Chrome. Those browsers contain a JavaScript interpreter to parse and run your JavaScript programs, which you write in plain text with a text editor. So, you can use the same text editor that you code your XHTML and CSS with. JavaScript derives its syntax, which is to say its grammar, from the ECMAScript standard and its features for manipulating XHTML, CSS, and HTTP from the DOM standard. Typically, JavaScript interpreters implement ECMAScript and DOM in separate libraries. So, just as your brain has left and right lobes, a browser’s JavaScript brain has ECMAScript and DOM lobes. In the first six chapters, we’ll converse with the ECMAScript lobe. Then we’ll converse with the DOM lobe for a couple of chapters. I guess you could say we’ll be picking a JavaScript’s brain one lobe at a time—ECMAScript and then DOM, with Firebug. Finally, in the last two chapters, we’ll hand-code an uber-cool JavaScript program with our preferred text editors. But we’ll never make it through Chapters 1–8 without Firebug. So, our first order of business will be to have you download and familiarize yourself with Firebug, a free add-on to Firefox for Windows, Mac, or Linux. Obviously, prior to installing a Firefox add-on like Firebug, you need to have Firefox. Note that Firefox is a free web browser for Windows, Mac OS X, or Linux. To download Firefox, go to www.mozilla.com, and click the Download Firefox – Free button, as displayed in Figure 1. Then follow the wizard to install Firefox on your computer.de+ha