Skip to content

Instantly share code, notes, and snippets.

@projektorius96
Forked from nanotroy/singlebang.js
Created April 27, 2020 08:40
Show Gist options
  • Save projektorius96/ad6f2ebabc8384cbc5de3fb89a6b40be to your computer and use it in GitHub Desktop.
Save projektorius96/ad6f2ebabc8384cbc5de3fb89a6b40be 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