Presentation is loading. Please wait.

Presentation is loading. Please wait.

By: Travis Powell and Chad Herman. About CoffeeScript The Golden Rule: o "Its just JavaScript" One-to-One Compilage into equivalent JavaScript Passes.

Similar presentations


Presentation on theme: "By: Travis Powell and Chad Herman. About CoffeeScript The Golden Rule: o "Its just JavaScript" One-to-One Compilage into equivalent JavaScript Passes."— Presentation transcript:

1 By: Travis Powell and Chad Herman

2 About CoffeeScript The Golden Rule: o "Its just JavaScript" One-to-One Compilage into equivalent JavaScript Passes through JSLint Runs as fast or faster than equivalent JavaScript

3 First Things First... White Space Delimiter o Semicolons ';' are useless Curly braces '{}' are unnecessary o Solved with indents or new lines Functions o () contains parameter list o -> points to the body

4 Variables and Conditions Compiler properly declares all variables within lexical scope Similar to Ruby's local variable scope All output wrapped in "hidden"(function(){...}) for safety If Statement o No '()' or '{}' o Typical  If....  else.... o However  and = &&  or = ||

5 Splat??? Splat =... Accept Variable number of arguments Useful for when function takes in many parameters

6 Loops For, While, Until, Do o Comprehensions over arrays, objects, ranges "Of" o iterate over keys/values of objects

7 Loops (Continued...)

8 Everything is an Expression Nothing requires "return" keyword o Always returns final value Good idea to return early

9 Conditional Operators Existential Operator In JS, "if (var)" is close o Fails on 0, "", and false In CoffeeScript o "?" returns true if null or undefined o Similar to Ruby's "nil?" o Good for null/undef chain of properties

10 Class Overviews

11 Switch Statements Typical Switch has o Switch cond: o case 1, break; case 2, break;...... Switch in CoffeeScript o Switch cond:  when... then... else o does not require "breaks" or "default"

12 The Cake is a Lie Cake is similar to Make o used to build and test tasks Tasks are set in....... o Cakefiles (like make files) Tasks can be invoked by typing "cake 'taskname' "

13 Demonstration http://jashkenas.github.com/coffee-script/

14 References 1. Ashkenas, Jeremy. "CoffeeScript." CoffeeScript. MIT, 2011. Web. 15 May 2011..


Download ppt "By: Travis Powell and Chad Herman. About CoffeeScript The Golden Rule: o "Its just JavaScript" One-to-One Compilage into equivalent JavaScript Passes."

Similar presentations


Ads by Google