Last active
February 28, 2020 15:07
-
-
Save NickyMeuleman/0904c970ada7e145f5aa35ff9062851b to your computer and use it in GitHub Desktop.
logical OR vs nullish coalescing
This file contains hidden or 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
const value = 0 | |
const defaultWithLogicalOR = value || 1 | |
// result: 1 | |
const defaultWithNullishCoalescing = value ?? 1; | |
// result: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment