chapter 2: code examples and descriptions are miscoordinated
vsemozhetbyt opened this issue · comments
It seems there is a conflict between some editions:
Consider the next snippet, where a property named
code
wouldn’t have been as indicative of its contents ascolorCode
could be:
var { metadata: { gender: characterGender } } = character
The scenario we just saw repeats itself frequently, because properties are often named in the context of their host object. While
palette.color.code
is perfectly descriptive,code
on its own could mean a wide variety of things, and aliases such ascolorCode
can help you bring context back into the variable name while still using destructuring.
Also:
In the following example we use the
value
alias, and a computed property name to extract theboots
property from thecharacter
object.var { ['boo' + 'ts']: characterBoots } = character console.log(characterBoots) // <- true