Skip to content

Instantly share code, notes, and snippets.

@smpnjn
Created December 5, 2020 15:38
Show Gist options
  • Save smpnjn/bd6a663bb6f567a69405f9da120a0865 to your computer and use it in GitHub Desktop.
Save smpnjn/bd6a663bb6f567a69405f9da120a0865 to your computer and use it in GitHub Desktop.
let foo = '';
let a = (3 - 3) || "this is falsy"; // returns "this is falsy" - 3 - 3 = 0 which is falsy
let b = (3 - 3) ?? "this is nullish"; // returns 0 - 3 - 3 = 0 which is not null or undefined
let c = foo || "this is falsy"; // returns "this is falsy" - since '' is falsy
let d = foo ?? "this is nullish"; // returns '' - since '' is not null or undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment