Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CoffeeScript

 CoffeeScript

How about a nice BIG cup of CoffeeScript

Jeroen Rosenberg

November 30, 2012
Tweet

More Decks by Jeroen Rosenberg

Other Decks in Programming

Transcript

  1. # prototyping String::downCase = -> @toLowerCase() # functions, chained comparison

    isMyAge = (age) -> 24 < age < 26 # splat arguments, pattern matching unCapitalize = (words...) -> (words.map ([firstChar, rest...]) -> firstChar.downCase() + rest.join '').join '' # destructuring assignment, function binding Me = ([surname, middlenames..., lastname] ) -> # string interpolation @name = "#{surname} #{lastname}" # everything is an expression @age = if isMyAge(x = 25) then x else '?' @twitter = unCapitalize('@', surname, lastname) # use jQuery (or any JavaScript library), multi line Strings $('#welcome').bind 'click' (event) => alert "Hello, I'm #{@name}!" # there's no var!! me = Me("Jeroen Matthijs Rosenberg".split ' ')