Skip to content

Instantly share code, notes, and snippets.

@Reinmar
Created December 9, 2011 16:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reinmar/1452344 to your computer and use it in GitHub Desktop.
Save Reinmar/1452344 to your computer and use it in GitHub Desktop.
JS ninja
// I've just found shit like this:
var sth =
option.type == 't1'
? v1
: option.type == 't2'
? v2
: option.type == 't3'
? v3
: null;
// You want to be JS ninja, so do it the right way:
var sth = {
t1: v1,
t2: v2,
t3: v3
}[option.type] || null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment