You are previewing CoffeeScript Programming with jQuery, Rails, and Node.js.

CoffeeScript Programming with jQuery, Rails, and Node.js

Cover of CoffeeScript Programming with jQuery, Rails, and Node.js by Michael Erasmus Published by Packt Publishing
  1. CoffeeScript Programming with jQuery, Rails, and Node.js
    1. Table of Contents
    2. CoffeeScript Programming with jQuery, Rails, and Node.js
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
      2. Why Subscribe?
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
    8. 1. Why CoffeeScript?
      1. CoffeeScript syntax
      2. CoffeeScript has great function syntax
      3. CoffeeScript handles scope better
      4. CoffeeScript has better object syntax
      5. A few other things CoffeeScript fixes
      6. List comprehensions
      7. Conditional clauses and logical aliases
      8. Array slicing and splicing
      9. Destructuring or pattern matching
      10. => and @
      11. Switch statements
      12. Chained comparisons
      13. Block strings, block comments, and strings
      14. Summary
    9. 2. Running CoffeeScript
      1. The CoffeeScript stack
      2. Node.js and npm
      3. Node.js, npm, and CoffeeScript on Windows
      4. Installing CoffeeScript on a Mac
      5. Installing CoffeeScript on Linux
      6. Building Node.js from source
      7. Using CoffeeScript
      8. The coffee command
      9. Summary
    10. 3. CoffeeScript and jQuery
      1. Finding and changing elements
      2. Utility functions
      3. Ajax methods
      4. Using jQuery
      5. Using CoffeeScript and jQuery in the browser
      6. Our application
      7. Summary
    11. 4. CoffeeScript and Rails
      1. What makes Rails special?
      2. Rails and JavaScript
      3. Rails and CoffeeScript
      4. Installing Rails
      5. Developing our Rails application
      6. Summary
    12. 5. CoffeeScript and Node.js
      1. Node is event-driven
      2. Node is fast and scalable
      3. Node is not Rails
      4. Node and CoffeeScript
      5. "Hello World" in Node
      6. Express
      7. WebSocket
      8. Jade
      9. Our application
      10. Let's get started
      11. Creating a view
      12. node-supervisor
      13. The to-do list view
      14. The client side
      15. Adding collaboration
      16. Creating the collaboration UI
      17. WebSocket on the client
      18. WebSocket on the server
      19. Joining a list
      20. Adding to-do items to a shared list
      21. Removing to-do items from a shared list
      22. Summary
    13. Index

A few other things CoffeeScript fixes

JavaScript has lots of other small annoyances that CoffeeScript makes nicer. Let's have a look at some of these.

Reserved words and object syntax

Often in JavaScript, you will need to make use of a reserved word, or a keyword that is used by JavaScript. This often happens with keys for literal objects as data in JavaScript, like class or for, which you then need to enclose in quotes. CoffeeScript will automatically quote reserved words for you, and generally you don't even need to worry about it.



tag = 
  type: 'label' 
  name: 'nameLabel'
  for: 'name'
  class: 'label'
var tag;

tag = {
  type: 'label',
  name: 'nameLabel',
  "for": 'name',
  "class": 'label'

Notice that we don't need the braces ...

The best content for your career. Discover unlimited learning on demand for around $1/day.