Check out a free preview of the full JavaScript: The Recent Parts course

The "Destructuring Exercise" Lesson is part of the full, JavaScript: The Recent Parts course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to destructure an AJAX response, then restructure the parameters.

Preview
Close

Transcript from the "Destructuring Exercise" Lesson

[00:00:00]
>> Kyle Simpson: All right, so we spend quite a bit of time digging into all the ins and outs of destructuring. It seems like a really good idea for us to get at least a teeny bit of practice with it. So we're gonna look at that example that I just showed you, which was the idea of using destructuring and restructuring as a declarative syntactic replacement for something like the underscore extends.

[00:00:22]
So here what you have is a defaults object, and we're making this fakeAjax call here. And it's going to give us a response back, which we are going to destructure, the code comment says where your destructuring goes. And then we need to restructure in the object that we passed along to the test case function.

[00:00:42]
And this should end up printing out true if you've properly done the destructuring and restructuring. So remember, just like from the slides, and refer back to the slides if you need that reference. But remember, we're gonna be restructuring and including the defaults in line with our destructuring pattern here in the handle response signature.

[00:01:02]
And then once we have those individual values assigned off, we're going to restructure the object that is expected to be passed along to the test case function. So we will break for a few moments and let you try your hand at destructuring. Remember, if you need any hints, cuz you get stuck, just take a look at the ex.fixed JavaScript file.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now