Skip to content

Instantly share code, notes, and snippets.

@nanotroy
Created June 28, 2019 18:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nanotroy/559d6ee40c43d96a462e6c4522ae9733 to your computer and use it in GitHub Desktop.
Save nanotroy/559d6ee40c43d96a462e6c4522ae9733 to your computer and use it in GitHub Desktop.
const x = 'abc'; // Coerces to true in a boolean context
const y = null; // Coerces to false in a boolean context
// "!" Creates a boolean context and returns the opposite.
const a = !x; // Value a is opposite of x, false.
const b = !y; // Value a is opposite of y, true.
if (a) {
// NOT executed.
}
if (b) {
// Executed.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment