Skip to content

Instantly share code, notes, and snippets.

@gryzzly
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gryzzly/dde04757391cec442527 to your computer and use it in GitHub Desktop.
Save gryzzly/dde04757391cec442527 to your computer and use it in GitHub Desktop.
logical OR vs array::some
return !!(// double negation is required since logical operators dont always return Booleans
  ENV_VAR || 
  SomeLongStore.get('key') ||
  SomeConfig.get('layer', 'sub-layer') === 'required-value' ||
  this.anotherLongCondition()
)

vs

return [
  ENV_VAR,
  SomeLongStore.get('key'),
  SomeConfig.get('layer', 'sub-layer') === 'required-value',
  this.anotherLongCondition()
].some(Boolean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment