Created
May 19, 2017 20:16
-
-
Save bluepnume/7c6128ba197d8eac00e94c4af39cbc98 to your computer and use it in GitHub Desktop.
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
// Register a pair of ES6 classes called "Animal" and "Cat" *without* inheritance, so I can do: | |
var animal = new Animal(); | |
animal.walk(); // logs 'The Animal walked' | |
var cat = new Cat(); | |
cat.walk(); // logs 'The Cat walked' | |
cat.meow(); // logs 'The Cat meowed' | |
console.log(cat instanceof Cat); // logs true | |
console.log(cat instanceof Animal); // logs false | |
// Note: I should only implement the logic in the *walk* function a single time, and use composition to let it be called from Cat |
wildlingjill
commented
May 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment