4 ms·
Exactly, I'm just pointing out the limitations of `let/const` I usually solve that case with let attribute1, attribute2; try { const object =
by madacol 7y ago
Exactly, I'm just pointing out the limitations of `let/const`
I usually solve that case with
let attribute1, attribute2;
try {
const object = getObject()
attribute1 = object.attribute1
attribute2 = object.attribute2
} catch () {}
But I'm just not satisfied with it, too many statements. And it gets really messy with many attributes
- decentralised 7y agoHow about this: let attribute1, attribute2; try { ({attribute1, attribute2} = getObject()) } catch (e) {}
- madacol 7y agowow, didn't know that! So parenthesis are the trick, thanks!
- decentralised 7y agoNo problem!