Created
June 17, 2015 09:10
-
-
Save DaRaFF/60aecf673c225c6edf02 to your computer and use it in GitHub Desktop.
Some notes on Coffeescript notation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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