You are currently in PREVIEW mode

Buy this book or become a member for full access.


JavaScript: Novice to Ninja

JavaScript: Novice to Ninja

JavaScript: Novice to Ninja

by Darren Jones
Product Manager: Simon Mackie
Technical Editor: Craig Buckler
English Editor: Kelly Steele
Cover Designer: Alex Walker

Notice of Rights

All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.

Notice of Liability

The author and publisher have made every effort to ensure the accuracy of the information herein. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any damages to be caused either directly or indirectly by the instructions contained in this book, or by the software or hardware products described herein.

Trademark Notice

Rather than indicating every occurrence of a trademarked name as such, this book uses the names only in an editorial fashion and to the benefit of the trademark owner with no intention of infringement of the trademark.

Published by SitePoint Pty. Ltd.

48 Cambridge Street Collingwood
VIC Australia 3066

Web: www.sitepoint.com
Email: business@sitepoint.com
Table of Contents
About the Author
Preface
Who Should Read This Book
Conventions Used
Supplementary Materials
Want to Take Your Learning Further?
1. Hello JavaScript
Programming
JavaScript
A Ninja Programming Environment
Your First JavaScript Program
JavaScript in the Browser
Unobtrusive JavaScript
Graceful Degradation and Progressive Enhancement
Your Second JavaScript Program
The Project: Quiz Ninja
Chapter Summary
2. Programming Basics
Comments
JavaScript Grammar
Data Types
Strings
Variables
Numbers
Undefined
Null
Booleans
Logical Operators
Bitwise Operators
Comparison
Quiz Ninja Project
Summary
3. Arrays, Logic, and Loops
Arrays
Array Properties and Methods
Logic
Loops
Quiz Ninja Project
Summary
4. Functions
Defining a Function
Return Values
Parameters and Arguments
Scope
Hoisting
Callbacks
Array Iterators
Quiz Ninja Project
Summary
5. Objects
Object Literals
Creating Objects
Built-in Objects
JSON
The Math Object
The Date Object
The RegExp Object
Roll the Dice!
Quiz Ninja Project
Summary
6. The Document Object Model
The Document Object Model
An Example Web Page
Getting Elements
Navigating the DOM Tree
Finding the Value of a Node
Getting and Setting Attributes
Classes of an Element
Updating the DOM by Creating Dynamic Markup
Live Collections
Updating CSS
Quiz Ninja Project
Summary
7. Events
Event Listeners
Example Code
The Event Object
Types of Events
Removing Event Listeners
Stopping Default Behavior
Event Propagation
Quiz Ninja Project
Summary
8. Forms
Forms
A Searching Example
Form Controls
Input Fields
I Need a Hero!
Form Validation
Quiz Ninja Project
Summary
9. The Window Object
The Browser Object Model
Browser Information
The Browser History
Controlling Windows
Screen Information
The Document Object
Timing Functions
Animation
Quiz Ninja Project
Summary
10. Testing and Debugging
Errors, Exceptions, and Warnings
The Importance of Testing and Debugging
Strict Mode
Feature Detection
Debugging in the Browser
Error Objects
Exception Handling
Tests
Quiz Ninja Project
Summary
11. Functional JavaScript
What is Functional Programming?
Function Properties and Methods
Callbacks
Closures
Immediately Invoked Function Expressions
Functions that Define and Rewrite Themselves
Recursive Functions
Currying
Quiz Ninja Project
Summary
12. Object-oriented Programming in JavaScript
Object-oriented Programming
Constructor Functions
Prototypal Inheritance
Public and Private Methods
Inheritance
The Object Constructor Function
Creating Objects from Objects
Adding Methods to Built-in Objects
Mixins
Chaining Functions
This and That
Borrowing Methods from Prototypes
Quiz Ninja Project
Summary
13. Ajax
Clients and Servers
A Brief History of Ajax
The XMLHttpRequest Object
Receiving Information
Sending Information
FormData
Ajax Timeouts
JSON With Padding
Quiz Ninja Project
Summary
14. HTML5 APIs
The Development of HTML5
The data- Attribute
HTML5 APIs
Drawing with Canvas
Shims and Polyfills
Quiz Ninja Project
Summary
15. Organizing Your Code
Frameworks
Modules
Package Managers
MVC Libraries
Templates
Minification
Task Runners
Deploying JavaScript
Quiz Ninja Project
Summary
16. Next Steps
What’s Next: ECMA6, Harmony
Ninja Skills
JavaScript Development Ideas
Summary

Have your say! or become a member now to take part in the discussion

Loading...

Code Archive

Save time, download the code archive here