Last active
May 7, 2021 21:46
-
-
Save TunvirRahman/9f06f25e4557b10a8247f902b07fe06d 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 someObject = { | |
| title: null, | |
| subTitle: "Subtitle", | |
| buttonColor: null, | |
| disabled: true | |
| }; | |
| function createOption(someObject) { | |
| someObject.title = someObject.title || "Default Title"; | |
| someObject.subTitle = someObject.subTitle || "Default Subtitle"; | |
| someObject.buttonColor = someObject.buttonColor || "blue"; | |
| someObject.disabled = someObject.disabled !== undefined ? someObject.disabled : true; | |
| return someObject | |
| } | |
| console.log(createOption(someObject)); | |
| // Output be like | |
| // {title: 'Default Title', subTitle: 'Subtitle', buttonColor: 'blue', disabled: true} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment