Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Last active August 29, 2015 14:16
Show Gist options
  • Save itsthatguy/48d9b47dba05b300c65b to your computer and use it in GitHub Desktop.
Save itsthatguy/48d9b47dba05b300c65b to your computer and use it in GitHub Desktop.
Coffeescript Classes: object.prototype.function and object.function demonstrated
# Run the following command in shell:
# curl -s https://gist.githubusercontent.com/itsthatguy/48d9b47dba05b300c65b/raw/80b1111bb5273697d1db4f5662eb763aa4a80cdc/foo.coffee | coffee --stdio
class Foo
name: 'abott'
@myFunction: ->
console.log "\n# start"
console.log "\nFoo"
console.log "this.name:", this.name
myOtherFunction: ->
console.log "\nfoo (instance of Foo)"
console.log "this.name:", this.name
console.log "\n# end"
Foo.myFunction()
foo = new Foo()
foo.myOtherFunction()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment