Do you know what will be the output of this code?
JavaScript
const { a = 1, b = 2 } = { a: null, b: undefined };
console.log(a, b);
Show answer and explanation
The answer is null 2.
Like default parameters, destructuring defaults only kick in for undefined. null is treated as a real value.
New to destructuring and arrow functions? Start with this intro to ES6 JavaScript features.