Created
March 2, 2022 00:03
-
-
Save alecat88/67be5b81b89907d85ceb77f40c564acd to your computer and use it in GitHub Desktop.
ES12
This file contains 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
// In the example, the ??= will check if the lastname is null or undefined. | |
// If null or undefined, then the right value will be assigned to the left variable. | |
let userDetails = {firstname: 'Katina', age: 24} | |
userDetails.lastname ??= 'Dawson'; | |
console.log(userDetails); // This will print: {firstname: 'Katina', age: 24, lastname: 'Dawson'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment