Skip to content

Instantly share code, notes, and snippets.

@DaRaFF
Created June 17, 2015 09:10
Show Gist options
  • Save DaRaFF/60aecf673c225c6edf02 to your computer and use it in GitHub Desktop.
Save DaRaFF/60aecf673c225c6edf02 to your computer and use it in GitHub Desktop.
Some notes on Coffeescript notation
class Animal
constructor: (name) ->
# @name is an instance property
@name = name
# This is an object function
# This function can be accessed with @getSomething() from the class itself
getSomething: -> return "hello"
# This is a class function
# This function can be accessed with Anmial.getSomethingElse() from the class itself
@getSomethingElse: -> return "hello"
class Test
# this is a class variable (its stored in prototype)
blubb: "bla"
constructor: ->
@blubb = "bazinga"
b = new Test
alert(b.blubb) # "bazinga"
b.blubb = "new value"
alert(b.blubb) # "new value"
c = new Test
alert(c.blubb) # "bazinga"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment