Benefits of destructuring assignments in Javascript

Viewed 3043

More and more often I come across code making use of the ES2015 introduced destructuring assignment and even more often I find it very hard to understand what the author is doing. I can see that destructuring can be very useful in some cases but I have the impression that it is often introducing unnecessary code complexity.

E.g. the Nested object and array destructuring example on MDN is using this line do destructure a nested array:

var { title: englishTitle, translations: [{ title: localeTitle }] } = metadata;

Where is the advantage over something like this, that looks a lot more readable to me:

var englishTitle = metadata.title,
    localeTitle  = metadata.translations[0].title;

What problems are being solved by destructuring assignments?

When to use them and when not to?

1 Answers
Related