Skip to content

Instantly share code, notes, and snippets.

@carlosrojaso
Created May 14, 2014 21:10
Show Gist options
  • Save carlosrojaso/7f1f6f021bd6cfd46b17 to your computer and use it in GitHub Desktop.
Save carlosrojaso/7f1f6f021bd6cfd46b17 to your computer and use it in GitHub Desktop.
JS Logical
// Do something with foo if foo is truthy.
foo && doSomething( foo );
// Set bar to baz if baz is truthy;
// otherwise, set it to the return value of createBar()
var bar = baz || createBar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment