Read more
If you're comfortable with jQuery but a bit shaky with JavaScript, this concise guide will help you expand your knowledge of the language - especially the code that jQuery covers up for you. Many jQuery devotees write as little code as possible, but with some JavaScript under your belt, you can prevent errors, reduce overhead, and make your application code more efficient.
This book explores event handling, prototypes, and working with the DOM and AJAX through examples and lots of code. You'll learn common conventions and patterns in JavaScript and - if you've never coded with JavaScript before - a tutorial will take you through the basics. Enhance your jQuery code by using object constructors and prototypes Reduce overhead and gain more control by handling events with JavaScript Work with the DOM much faster with JavaScript than you can with jQuery Send a few AJAX requests without having to load the entire jQuery library Understand the importance of JavaScript code standards, comments, code reuse, and anti-patterns Enlist JavaScript resources, such as a good IDE, a syntax checker, and version control
List of contents
Preface;
Who This Book Is For;
Who This Book Isn't For;
Conventions Used in This Book;
Using Code Examples;
Safari® Books Online;
How to Contact Us;
Acknowledgments;
Chapter 1: Event Handling;
1.1 Listening for Events;
1.2 Event Propagation;
1.3 Triggering Events;
1.4 Removing Event Handlers;
1.5 Adding a "Once Only" Event Listener;
1.6 Summary;
Chapter 2: Constructors and Prototypes;
2.1 Constructors;
2.2 Prototypes;
2.3 Summary;
Chapter 3: DOM Traversal and Manipulation;
3.1 Selecting an Element;
3.2 Selecting Children;
3.3 Selecting the Next Element;
3.4 Creating an Element;
3.5 Modifying an Existing Element;
3.6 Cycling Through Elements;
3.7 Moving and Copying Elements;
3.8 Summary;
Chapter 4: AJAX;
4.1 Sending an AJAX Request;
4.2 Debugging;
4.3 Sending POST Requests in JavaScript;
4.4 Writing a Wrapper Function;
4.5 A Simple Application of AJAX;
4.6 Designing a Site with AJAX;
4.7 Summary;
Chapter 5: JavaScript Conventions;
5.1 Writing JavaScript;
5.2 Literals Notation;
5.3 Optimizations;
5.4 Functions;
5.5 Code Reuse;
5.6 Common Antipatterns;
5.7 Common Design Patterns;
5.8 Summary;
JavaScript Basics;
Hello World!;
Comments;
Variables;
Numbers;
Functions;
Objects;
Finding the Type of a Variable;
Arrays;
Looping;
Conditional Statements;
Delays;
Regular Expressions;
Error Handling;
Summary;
JavaScript Resources;
A Good IDE;
GitHub;
JSHint;
JSPerf;
Mozilla Developer Network;
Pastebins;
Version Control Software;
Colophon;
About the author
Callum Macrae is a professional JavaScript developer based in the UK. He regularly contributes JavaScript related patches to open source projects, including phpBB and jQuery++. When not coding or writing, he spends most of his time drumming or cycling.
Summary
If you’re comfortable with jQuery but a bit shaky with JavaScript, this concise guide will help you expand your knowledge of the language—especially the code that jQuery covers up for you. Many jQuery devotees write as little code as possible, but with some JavaScript under your belt, you can prevent errors, reduce overhead, and make your application code more efficient.
This book explores event handling, prototypes, and working with the DOM and AJAX through examples and lots of code. You’ll learn common conventions and patterns in JavaScript and—if you’ve never coded with JavaScript before—a tutorial will take you through the basics.
* Enhance your jQuery code by using object constructors and prototypes
* Reduce overhead and gain more control by handling events with JavaScript
* Work with the DOM much faster with JavaScript than you can with jQuery
* Send a few AJAX requests without having to load the entire jQuery library
* Understand the importance of JavaScript code standards, comments, code reuse, and anti-patterns
* Enlist JavaScript resources, such as a good IDE, a syntax checker, and version control