Created
September 21, 2015 16:36
-
-
Save Anaphase/f73fcd5047d311f1cb62 to your computer and use it in GitHub Desktop.
CoffeeScript Class Cheatsheet
This file contains 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 ClassName | |
# shared via closure over constructor | |
# class and instance functions have access to this variable | |
privateVariable = 'privateVariable' | |
# shared via closure over constructor | |
# not exposed in instance | |
# doesn't have access to instance | |
# @ is the window object | |
# class and instance functions have access to this function | |
privateFunction = -> 'privateFunction' | |
# shared via prototype | |
classVariable: 'classVariable' | |
# shared via prototype | |
classFunction: -> 'classFunction' | |
constructor: -> | |
# unique per instance | |
# not exposed in instance | |
# only instance functions have access to this variable | |
instancePrivateVariable = 'instancePrivateVariable' | |
# unique per instance | |
# not exposed in instance | |
# has access to instance as @ | |
# only instance functions have access to this function | |
instancePrivateFunction = => 'instancePrivateFunction' | |
# unique per instance | |
@instanceVariable = 'instanceVariable' | |
# unique per instance | |
@instanceFunction = -> 'instanceFunction' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment