Skip to content

Instantly share code, notes, and snippets.

@manuelcabral
Last active December 16, 2015 18:59
Show Gist options
  • Save manuelcabral/5481760 to your computer and use it in GitHub Desktop.
Save manuelcabral/5481760 to your computer and use it in GitHub Desktop.
Switch inside object literal
param = 'foo'
someObject =
someKey: 'some value'
someOtherKey: switch param
when 'foo' then "something"
when 'bar' then "something else"
when 'fooo' then "something different"
else "some other thing"
console.log(someObject.someOtherKey)
#>something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment