Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.