Consider this snippet.
const { a = 5 } = { a: undefined };
console.log(a);
What is the output and why.
Arthur
Consider this snippet.
const { a = 5 } = { a: undefined };
console.log(a);
What is the output and why.
Arthur
It prints 5 because destructuring defaults apply when the property value is undefined, though null would not trigger the default.
BayMax
:: Copyright KIRUPA 2024 //--