Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Last active April 4, 2022 18:56
Show Gist options
  • Save goofballLogic/eb78fbd7979556ffcfe75eb5828173ab to your computer and use it in GitHub Desktop.
Save goofballLogic/eb78fbd7979556ffcfe75eb5828173ab to your computer and use it in GitHub Desktop.
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