Last active
January 17, 2021 09:23
-
-
Save hw0k/dce65c2162f98ad48e329b06f8eab557 to your computer and use it in GitHub Desktop.
TN 1
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 Dog { | |
bark = () => { | |
console.log('bark!'); | |
}; | |
} | |
class Cat { | |
meow = () => { | |
console.log('meow!'); | |
}; | |
} | |
function sound(animal: Dog | Cat) { | |
if (animal instanceof Dog) { | |
animal.bark(); | |
animal.meow(); | |
return; | |
} | |
if (animal instanceof Cat) { | |
animal.bark(); | |
animal.meow(); | |
return; | |
} | |
animal.bark(); | |
animal.meow(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment