Skip to content

Instantly share code, notes, and snippets.

@timmarinin
Last active August 29, 2015 13:57
Show Gist options
  • Save timmarinin/9352919 to your computer and use it in GitHub Desktop.
Save timmarinin/9352919 to your computer and use it in GitHub Desktop.
Coffeescript Cheatsheet (doge)

Declarations

Variables: muchVar = soValue

Making global var: global.muchVar = soValue

Objects:

muchObj =
    soProp: "wow"
    veryUse: "much economy"

Arrays: soArr = []

Comments: #very comment

Functions

###Calling existing functions

veryOld muchParameterOne, soManyParameter, wow # → veryOld(muchParameterOne, soManyParameter, wow);

Anonymous Function.

(arg) -> 
    body

(arg) is optional

->
    body

Anonymous function with this binding

(muchArg) =>
    this.veryBinding

IIFE

Immediately Invoked Function Expression.

(arg, ...) is optional

do (arg, ...) ->
    bodyOfFunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment