Last active
April 4, 2022 18:56
-
-
Save goofballLogic/eb78fbd7979556ffcfe75eb5828173ab to your computer and use it in GitHub Desktop.
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 Cat { | |
speak() { return "meow"; } | |
} | |
function process(cat) { | |
return cat.speak(); | |
} | |
class Ball { | |
} | |
function processAnything(x) { | |
if(x instanceof Cat) { | |
return process(x); | |
} | |
} | |
processAnything(new Cat()); // => "meow" | |
processAnything(new Ball()); // => undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment