Demos created for public lecture in VarnaLab (02 October 2013)
Github Demos : https://github.com/dimitardanailov/coffeescript-intro
Agenda :
Introduction
Installing CoffeeScript
Using CoffeeScript Files
Learning the Core Functionality
Data Types
Comments and Functions
Operators
Control Structures
Loops and Comprehensions
Scope and Context
Stirring in Advanced Concepts
Object Prototypes
CoffeeScript Classes
Heregexes
Using CoffeeScript in the Browser
2. CoffeeScript : Intro
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Github
Founder at VarnaIT
Senior Developer at 158ltd.com
Cleaner Code With CoffeeScript
Github Code
3. Topics Today
● Introduction
● Installing CoffeeScript
● Using CoffeeScript Files
● Learning the Core Functionality
● Data Types
● Comments and Functions
● Operators
4. Topics Today (2)
● Control Structures
● Loops and Comprehensions
● Scope and Context
● Stirring in Advanced Concepts
● Object Prototypes
● CoffeeScript Classes
● Heregexes
● Using CoffeeScript in the Browser
11. Functions
Splats :
The JavaScript arguments object is a useful way to work with functions that
accept variable numbers of arguments. CoffeeScript provides splats ..., both
for function definition as well as invocation, making variable numbers of
arguments a little bit more palatable.
# Splats:
race = (winner, runners...) ->
print winner, runners
12. Operators
● JS : == / Coffee : is
● JS : != / Coffee : isnt
● JS : if (!false) / Coffee : if not false
● JS : && / Coffee : AND
● JS : || / Coffee : OR
14. Loops and Comprehensions
Most of the loops you'll write in CoffeeScript will be comprehensions over
arrays, objects, and ranges. Comprehensions replace (and compile into) for
loops, with optional guard clauses and the value of the current array index.
Unlike for loops, array comprehensions are expressions, and can be returned
and assigned.
19. Regular Expressions
Similar to block strings and comments, CoffeeScript supports block regexes
— extended regular expressions that ignore internal whitespace and can
contain comments and interpolation. Modeled after Perl's /x modifier,
CoffeeScript's block regexes are delimited by /// and go a long way towards
making complex regular expressions readable.
20. Using CoffeeScript in the Browser
● coffee -c --watch *.coffee
● coffee -c --watch o js src/*.coffee
● http://coffeescript.org/#scripts
21. Questions ?
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Github
Founder at VarnaIT
Senior Developer at 158ltd.com
Cleaner Code With CoffeeScript
Github Code