Is that how you pass on real-world code a generic person data around?
Is that how you don't use i18n for string and how you ignore occupations that starts with vowels?
Destructuring is nice as other new features in ES6 but abusing these just because there are there ... no, I don't think that's going to improve any code or any readability.
So:
const description = (nameAndOccupation) => {
const { name: { first, last }, occupation } = nameAndOccupation;
return `${first} is a ${occupation}`;
}
description({ name: { first: "Reginald", last: "Brathwaite" }, occupation: "programmer" });
And this last _is_ in fact how real-world code would pass person data around. Your i18n points stand, of course. const description = ({name: {first, last}, occupation}) => `${first} is a ${occupation}`;
Edit: just noticed that `last` is not used, so we can remove it from the destructuring: const description = ({name: {first}, occupation}) => `${first} is a ${occupation}`;For that matter, maybe even messagepack, protocol buffers , etc over 0mq or direct sockets... although straight json + gzip is pretty effective.
function describe(nameAndOccupation){ return `${nameAndOccuptation.name.first} is a ${nameAndOccupation.occupation}`; } ?
When people use features purely for the sake of using those features, the result is not "more readable". Ever notice that pseudocode is almost always imperative?