CoffeeScript: Accelerated JavaScript Development

CoffeeScript: Accelerated JavaScript Development

by Trevor Burnham

Paperback

$29.00
View All Available Formats & Editions
Eligible for FREE SHIPPING
  • Want it by Tuesday, October 23?   Order by 12:00 PM Eastern and choose Expedited Shipping at checkout.

Overview

CoffeeScript: Accelerated JavaScript Development by Trevor Burnham

Over the last five years, CoffeeScript has taken the web development world by storm. With the humble motto "It's just JavaScript," CoffeeScript provides all the power of the JavaScript language in a friendly and elegant package. This extensively revised and updated new edition includes an all-new project to demonstrate CoffeeScript in action, both in the browser and on a Node.js server. There's no faster way to learn to write a modern web application.

This new edition has been extensively revised and updated to reflect the current state and features of CoffeeScript. Every chapter has been revised and refactored, and new sections and a new chapter on testing have been added. If you already know JavaScript, this book will make your transition to CoffeeScript easy. If you're new to JavaScript, it's a great place to start.

New in this edition:

Automating setup with the Grunt task runner

Using CoffeeScript classes with the Backbone framework

Using CoffeeScript's simple callback syntax to interact with the Express framework

A new chapter on client-side and server-side testing with Intern

* A new project that gives you hands-on experience with browser-side and server-side CoffeeScript

CoffeeScript is every bit as portable and effective as JavaScript. It aids development by adding a bevy of features, such as classes, splats, list comprehensions, and destructuring. These features make it easier to write clear, readable code, and by learning how these features work, you'll deepen your understand of JavaScript as well. This book is your complete guide to writing better JavaScript code, faster.

Product Details

ISBN-13: 9781941222263
Publisher: Pragmatic Programmers, LLC, The
Publication date: 02/16/2015
Pages: 124
Product dimensions: 7.40(w) x 9.20(h) x 0.20(d)

About the Author

Trevor Burnham is a full-stack web developer living in Cambridge, MA. You can reach him on Twitter, where he goes by @TrevorBurnham and @CoffeeScript.

Table of Contents

Foreword xi

Acknowledgments xiii

Preface xv

1 Getting Started 1

1.1 Installing CoffeeScript 1

1.2 Text Editors for CoffeeScript 5

1.3 Meet'coffee' 6

1.4 Debugging CoffeeScript 9

2 Functions, Scope, and Context 13

2.1 Functions 101 13

2.2 Scope: Where You See 'Em 18

2.3 Context (or, "What Is 'this'?") 21

2.4 Property Arguments (@arg) 24

2.5 Default Arguments (arg =) 25

2.6 Splats (…) 28

2.7 Project: 5x5 Input Parser 29

2.9 Exercises 34

3 Collections and Iteration 37

3.1 Objects as Hashes 37

3.2 Arrays 40

3.3 Iterating over Collections 43

3.4 Conditional Iteration 46

3.5 Comprehensions 47

3.6 Pattern Matching (or, Destructuring Assignment) 48

3.7 Project: 5x5 Solitaire 50

3.9 Exercises 56

4 Modules and Classes 59

4.1 Modules: Splitting Up Apps 60

4.2 The Power of Prototypes 61

4.3 Classes: Functions with Prototypes 63

4.4 Inheritance with 'extends' 65

4.5 Project: Refactoring 5x5 68

4.7 Exercises 72

5 Web Interactivity with jQuery 75

5.1 The Tao of jQuery 76

5.2 Manipulating the DOM 76

5.3 Getting Selective 77

5.4 Reacting to Events 79

5.5 Project: Browser-Based 5x5 80

5.7 Exercises 87

6 Server-Side Apps with Node.js 89

6.1 What Is Node.js? 89

6.2 Modularizing Code with 'exports' and 'require' 90

6.3 Thinking Asynchronously 91

6.4 Project: Multiplayer 5x5 95

6.6 Exercises 103

A1 Answers to Exercises 105

A1.1 Functions, Scope, and Context 105

A1.2 Collections and Iteration 107

A1.3 Modules and Classes 109

A1.4 Web Interactivity with jQuery 110

A1.5 Server-Side Apps with Node.js 111

A2 Ways of Running CoffeeScript 113

A2.1 Web Consoles 113

A2.2 Running CoffeeScript in Your Web App 114

A2.3 CoffeeScript on Rails 114

A2.4 CoffeeScript via Middleware 115

A2.5 CoffeeScript on Node.js 115

A2.6 Rapid Websites with Middleman 116

A2.7 CoffeeScript for System Scripts 117

A3 Cheat Sheet for JavaScripters 119

A3.1 Boolean Operators 119

A3.2 The Existential Operator 119

A3.3 Context and Prototype Accessors 120

A3.4 Function Definitions 120

A3.5 Conditionals 120

A3.6 Property Existence 120

A3.7 Iteration 121

A4 Bibliography 123

Index 125

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews