Solution Review: Destructuring
This lesson will explain the solution to the problem in the previous lesson.
We'll cover the following...
Solution #
Press + to interact
function display(){const exampleObject = {collection: [{name: "Kelly",}, {name: "Anna",}],}const { collection: [,{name: secondObject,}] } = exampleObjectconsole.log(secondObject)}display()
Explanation #
This problem has a one-line solution. Let’s start by discussing what exampleObject
contains:
const exampleObject = {
collection : [
{name: "kelly",},
{name:
...