Created
October 26, 2021 16:02
-
-
Save RGBz/c960b643936efadbd0b12441479a4c97 to your computer and use it in GitHub Desktop.
Deleting from an optional chain
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 x = { y: 1 }; | |
// Delete a key that doesn't exist from an optional chain | |
delete x?.y?.z; | |
// This results in: | |
// > {"y":1} | |
console.log(JSON.stringify(x)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment