Created
March 9, 2015 23:56
-
-
Save maxbeatty/31812238521aae74c9cd to your computer and use it in GitHub Desktop.
CoffeeScript Class Constructor Names
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: -> | |
@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