Created
November 13, 2024 19:59
-
-
Save benhatsor/4b7fe98dba4a1973f0103008a5115c6d to your computer and use it in GitHub Desktop.
Optional function arguments with object destructuring.
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
function a(b, { c = 1 } = {}) { | |
console.log(b, c); | |
} | |
// a(2) -> '2 1' | |
// a(2, { c: 3 }) -> '2 3' | |
// a(2, {}) -> '2 1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment