Simple JavaScript output question.
const { a = 5 } = { a: undefined };
console.log(a);
What is the output and why.
Ellen ![]()
Simple JavaScript output question.
const { a = 5 } = { a: undefined };
console.log(a);
What is the output and why.
Ellen ![]()
It prints 5, because destructuring defaults kick in when the property value is undefined-if it were null, you’d get null instead.
Yoshiii
:: Copyright KIRUPA 2024 //--