• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Coffeescript   intro
 

Coffeescript intro

on

  • 1,299 views

Demos created for public lecture in VarnaLab (02 October 2013) ...

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

Statistics

Views

Total Views
1,299
Views on SlideShare
999
Embed Views
300

Actions

Likes
0
Downloads
2
Comments
0

3 Embeds 300

http://itweb-projects.com 291
http://cloud.feedly.com 5
https://twitter.com 4

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Coffeescript   intro Coffeescript intro Presentation Transcript

    • CoffeeScript CoffeeScript - Intro @d_danailov
    • 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
    • Topics Today ● Introduction ● Installing CoffeeScript ● Using CoffeeScript Files ● Learning the Core Functionality ● Data Types ● Comments and Functions ● Operators
    • 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
    • Installing CoffeeScript 1. Node.js 2. NPM sudo apt-get install nodejs npm && 3. sudo npm install -g coffee-script 4. coffee -v
    • Using CoffeeScript Files node.js file.js coffee file.coffee coffee -c file.coffee coffee -cw file.coffee coffee (read–eval–print loop (REPL))
    • Variables Booleans : ● true/false ● yes/no ● on/off
    • Variables (2) Destructuring Assignment : theBait = 1000 theSwitch = 0 [theBait, theSwitch ] = [theSwitch, theBait]
    • Variables (3) Destructuring Assignment : weatherReport = (location) -> # Make an Ajax request to fetch the weather... [location, 72, "Mostly Sunny" ] [city, temp, forecast ] = weatherReport "Berkeley, CA"
    • Comments # Single line comment ### Multi line comment ###
    • 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
    • Operators ● JS : == / Coffee : is ● JS : != / Coffee : isnt ● JS : if (!false) / Coffee : if not false ● JS : && / Coffee : AND ● JS : || / Coffee : OR
    • Condition statements ● if ● if not ● unless ● switch and when
    • 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.
    • Loops ● for ● while ● until ● loop used with break !!!
    • Scope ● coffee -c --bare file.coffee ● this ● root = (export ? window)
    • Prototype
    • Classes
    • 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.
    • Using CoffeeScript in the Browser ● coffee -c --watch *.coffee ● coffee -c --watch o js src/*.coffee ● http://coffeescript.org/#scripts
    • 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