Skip to content

Instantly share code, notes, and snippets.

@jsdryan
Created February 28, 2022 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsdryan/157dfbdce00dea6e13fe33ff64c860ab to your computer and use it in GitHub Desktop.
Save jsdryan/157dfbdce00dea6e13fe33ff64c860ab to your computer and use it in GitHub Desktop.
// Show content if first variable is ture.
const theBoolean = true;
const thing = 'the awesome thing';
theBoolean && thing; // the awesome thing
// Judge the boolean of 'undefined', '', false
let userInput = '';
!!userInput; // false
let userInput; = undefined;
!!userInput; // false
let userInput = false;
!!userInput; // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment