Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created February 27, 2021 10:15
Show Gist options
  • Save d1i1m1o1n/d2a5391f09a1834597991d5793a3307c to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/d2a5391f09a1834597991d5793a3307c to your computer and use it in GitHub Desktop.
Alternative to switch case
const page = 'edit';
const content = {
create: () => console.log('create'),
edit: () => console.log('edit'),
view: () => console.log('view')
}[page]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment