2. About CoffeeSCript
• The Golden Rule:
o "Its just JavaScript"
• One-to-One Compilage into
equivalent JavaScript
• Runs as fast or faster than
equivalent JavaScript
3. The code writing and use process of CoffeeScript is
simple:
Write your code in a .coffee file
Compile it into a .js file
Include the .js file in your web page/s like you
would any other JavaScript file
4. COMMAND THROUGH
coffee --watch --compile try.coffee
DIRECT IN HTML FILE
<script src="https://jashkenas.github.com/coffee-
script/extras/coffee-script.js"
type="text/javascript"></script>
6. Variables
There is no need to declare variable in cofeescript.
For e.g.:
**javascript**
var message;
message=“ready for some cofeescript”
alert(message);
**coffeescript**
message=“ready for some cofeescript”
alert(message)
7. Function
• 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
8. Array
Arrays can use whitespace instead of comma separators,
although the square brackets ([]) are still required.
array1 = [1, 2, 3]
array2 = [ 1
2
3
]
10. 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"