Getting Good with JavaScript - Andrew Burgess [0]
Envato.com
© Rockable Press 2011
All rights reserved. No part of this publication may be reproduced or redistributed in any form without the prior written permission of the publishers.
Table of Contents
Getting Started
Aren’t There Already Enough JavaScript Books?
What Will I Learn?
Where Did JavaScript Come From?
How Do I Get Started?
Conventions Used in This Book
Summary
The Basics
Variables
Types
Semicolons
Comments
Operators
Conditional Statements
Looping Statements
Summary
More Basics
Functions
Type Methods
Summary
More Concepts and Best Practices
this
Object Oriented JavaScript
Object Methods
Closure
Errors
Testing your JavaScript
Organizing your JavaScript
Optimizing your JavaScript
Summary
Working with HTML
Kids, Meet the DOM
Nodes
Finding Elements
Traversing the DOM
Adding, Removing, and Modifying Elements
Events
The DOM, In Sum
Wrapping Up
Appendix A: Further Study
Appendix B: What We Didn’t Cover
About The Author
Your Screencasts
Getting Started
Thanks for buying "Getting Good with JavaScript." I'm pretty sure you've made the right decision (if I'm allowed to say that). This introductory chapter will get you acquainted the subject under the microscope. Let's roll!
Aren't There Already Enough JavaScript Books?
There's a pretty good chance that you rolled your eyes when you first saw this book. If you've followed the online development community for any time at all, you'll know that JavaScript is a pretty hot topic. Everybody is writing about it. So why yet another book on JavaScript?
Well, yet another JavaScript book because I hope this book fills a niche. From the beginning, I wanted this book to be one that would take someone who knows little or nothing about JavaScript and get them up to speed in very little time … while only teaching current methods and best practices. This means that there's much more to JavaScript than you'll find in this book. There are many things you really don't need to know when you get started; I won't be spending time on them. I've seen other beginner books that cover things I've left out, and that's okay, because they're aiming for comprehensiveness. But not in this book: here, you'll only learn what you'll actually use as you dip your toes into JavaScript. That other stuff can wait.
Since I've tried to keep this book short enough to read in a weekend (well, maybe a long weekend), many of the things we'll look at aren't exhaustively covered. This doesn't mean I'll skim over things. It just means that there are more advanced techniques that aren't important for you to learn at this time. Don't worry: you'll get a solid grounding in what you need to know to get you off the ground. Then, check out some of the resources in the Appendices for further study.
What Will I Learn?
Before we get started, let's talk about what this book covers. In this chapter, you'll get acquainted with what JavaScript is and where it came from. We'll also talk about how to set up an environment for coding JavaScript.
After that, we'll cover the basics in Chapters 2 and 3. You'll learn all about the core syntax: what to actually type. Chapter 4 will cover many best practices and important concepts for writing JavaScript. Then, in Chapter 5, I'll introduce you to the basics of writing JavaScript that interacts with web pages.
Where Did JavaScript Come From?
JavaScript was developed by a gentleman named Brendan Eich, who was working for Netscape (a now non-existent web browser maker) at the time—he built the whole language in less than two weeks. Originally, it was called Mocha, then LiveScript, and finally JavaScript. The first browser to support JavaScript was Netscape Navigator 2.0, way back in late 1995.
For a long time, JavaScript wasn't considered to be much of a language. The "big idea" on the web was supposed to be Java Applets. However, they failed, and eventually, JavaScript's "Good Parts" became well-known and soon even loved by many people.
Now, JavaScript is the most used programming language in the