Created
July 16, 2019 14:40
-
-
Save iandesj/e0bdc41dcd242fe11e594113f39ca7c8 to your computer and use it in GitHub Desktop.
Named Boolean Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// before named boolean expressions | |
// check if the user is active and if the user has | |
// dependents | |
if (user.status === 'active' && | |
user.dependents.length > 1) { | |
// perform something important | |
} | |
// before | |
if (!user.authenticated) { | |
// take special action | |
} | |
// after named boolean expressions | |
const userIsActiveWithDependents = user.status === 'active' && | |
user.dependents.length > 1; | |
if (userIsActiveWithDependents) { | |
// perform something important | |
} | |
// after | |
const userIsUnauthenticated = user.authenticated == false; | |
if (userIsUnauthenticated) { | |
// take special action | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment