When extracting a variable from an object, is there a way to already check there if it’s undefined and set a default? I’m basically trying to achieve the below code in one line:
let { name } = user
name ??= "John"
>Solution :
let { name = "John" } = user;
(destructuring on MDN)