Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const doSomething = () => {}
- const doSomethingElse = () => {}
- const doMagic = () => {}
- let cases = {
- 'a': doSomething,
- 'b': doSomethingElse,
- 'c': doMagic
- };
- let key = ???;
- if (containsKey(cases, key)) {
- cases[key]();
- } else {
- console.log("I don't know what to do!");
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement