Skip to content

Instantly share code, notes, and snippets.

@maxbeatty
Created March 9, 2015 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxbeatty/31812238521aae74c9cd to your computer and use it in GitHub Desktop.
Save maxbeatty/31812238521aae74c9cd to your computer and use it in GitHub Desktop.
CoffeeScript Class Constructor Names
class Animal
constructor: ->
@noise = "BOOM"
speak: -> console.log @noise
class Dog extends Animal
constructor: ->
@noise = "BARK"
class Boxer extends Dog
constructor: ->
@noise = "WOOF"
b = new Boxer
b.speak()
console.log "--"
console.log b.__proto__.constructor.name # Boxer
console.log b.__proto__.__proto__.constructor.name # Dog
console.log b.__proto__.__proto__.__proto__.constructor.name # Animal
console.log "--"
console.log Boxer::constructor.name # Boxer
console.log Boxer::__proto__.constructor.name # Dog
console.log Boxer::__proto__.__proto__.constructor.name # Animal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment