Last active
August 5, 2019 11:11
-
-
Save indreklasn/ab52f675a81b35f87cd765b4922aa6dc 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 response = { | |
settings: { | |
nullValue: null, | |
height: 400, | |
animationDuration: 0, | |
headerText: '', | |
showSplashScreen: false | |
} | |
}; | |
// result: 'some other default' | |
const undefinedValue = response.settings.undefinedValue ?? 'some other default'; | |
// result: 'some other default' | |
const nullValue = response.settings.nullValue ?? 'some other default'; | |
// result: '' | |
const headerText = response.settings.headerText ?? 'Hello, world!'; | |
// result: 0 | |
const animationDuration = response.settings.animationDuration ?? 300; | |
// result: false | |
const showSplashScreen = response.settings.showSplashScreen ?? true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment