Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Last active September 13, 2019 16:43
Show Gist options
  • Save lolmaus/5abbc25f6147494add47fe3b31231ac5 to your computer and use it in GitHub Desktop.
Save lolmaus/5abbc25f6147494add47fe3b31231ac5 to your computer and use it in GitHub Desktop.
Ternary vs ifs
const isHidden =
option.selectable !== undefined ? option.selectable :
hasOptedIntoDisabledOptions ? values.all.length > 1 :
getAvailableOptionValues(option, state, constraints).length > 1 ;
let isHidden;
if (option.selectable !== undefined) {
isHidden = option.selectable;
} else if(hasOptedIntoDisabledOptions) {
isHidden = values.all.length > 1
} else {
isHidden = getAvailableOptionValues(option, state, constraints).length > 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment