destructuring assignment default value [duplicate]
问题 This question already has an answer here : destructuring falsey and null with default parameters (1 answer) Closed 2 years ago . I am learning javascript and I got kind of stuck with ES6 syntax while trying to give a default value to a variable when destructuring. Basically, I am trying to assign a variable giving the value of an object's property to it and if the value is false/null/undefined, I want it to be an empty object. For example, let foo = { prop1: 'hello!', prop2: null } const