if the level of the object that needs to be deconstructed is deep, and the object may be {}, which way is better?
1.
try {
var { itemData: {
couponName, agentName, logo, pid, status, statusText
},
requestKey
} = this.props || {};
} catch (error) {
couponName = null;
agentName = null;
logo = null;
pid = null;
status = null;
statusText = null;
}
2.
var { couponName, agentName, logo, pid, status, statusText } = this.props.itemData || {};
var { requestKey } = this.props || {};
some people say that the second way of writing is inconvenient to continue deconstructing when adding attributes, but in the first way, there are too many catch, so it doesn"t look good, and if it"s less, it"s okay. I don"t know how to write some suitable-sharp-sharp-sharp problem description
.the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)