Skip to content

Instantly share code, notes, and snippets.

@sym3tri
Last active January 10, 2019 09:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sym3tri/911166 to your computer and use it in GitHub Desktop.
Save sym3tri/911166 to your computer and use it in GitHub Desktop.
How AND, OR, and COMMA operators are evaluated in JavaScript
//(LHE: left hand expression, RHE right hand expression)
LHE && RHE
1. Always evaluate LHE
2. If LHE is true, evaluate RHE
LHE || RHE
1. Always evaluate LHE
2. If LHE is false, evaluate RHE
LHE, RHE
1. Always evaluate LHE
2. Always evaluate RHE
credit: http://javascriptweblog.wordpress.com/2011/04/04/the-javascript-comma-operator/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment