This code gets a state from a query string hash part, converts the hash part to a JavaScript object and then tries to get a view
, dashboard
or a mode
value. If those keys are not present in object, it returns $.pulse.qs.views.home
.
Does this JavaScript code with ternary operator follow common best practices? It looks like ternary operator abuse and it is not readable. Or is it just me?
var state = $.query.getState();
var screen = state[$.pulse.qs.view]
? state[$.pulse.qs.view]
: state[$.pulse.qs.dashboard] || state[$.pulse.qs.mode]
? $.pulse.qs.views.dashboard
: $.pulse.qs.views.home;