Created
April 26, 2020 20:08
-
-
Save annacoding2020/b40bed720a63c5b628b329b59ac7022c to your computer and use it in GitHub Desktop.
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 nullValue = null; | |
| const emptyText = ""; // falsy | |
| const someNumber = 42; | |
| const valA = nullValue ?? "default for A"; | |
| const valB = emptyText ?? "default for B"; | |
| const valC = someNumber ?? 0; | |
| console.log(valA); // "default for A" | |
| console.log(valB); // "" (as the empty string is not null or undefined) | |
| console.log(valC); // 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment