1 00:00:02,020 --> 00:00:07,840 So next, we're going to talk about a raid, restructuring and restructuring, all that means is to 2 00:00:07,840 --> 00:00:09,450 unpack the array elements. 3 00:00:11,950 --> 00:00:19,660 So what you can do is if you have an array and you assign it to another array like Array X, comma Y, 4 00:00:19,680 --> 00:00:24,640 this is kind of an array of variables equals one, two, three, four, five. 5 00:00:25,420 --> 00:00:31,210 It's going to assign the one to X and the two to Y in the three, four or five. 6 00:00:31,210 --> 00:00:33,070 Just get the fall off the end. 7 00:00:35,760 --> 00:00:42,720 You can skip one or more by saying, let X, comma, comma, Y equals one, two, three, four or five, 8 00:00:43,740 --> 00:00:46,820 X is going at one, Y is going to get three and it's going to get two. 9 00:00:48,300 --> 00:00:52,350 And then finally, there's what's called the rest operator, which looks a lot like the spread operator 10 00:00:52,350 --> 00:00:53,820 because it's a dot, dot, dot. 11 00:00:54,270 --> 00:00:56,230 But what it just means is put the rest here. 12 00:00:57,630 --> 00:01:05,730 And so when I say let X. comma, dot, dot, dot more, it's going to put one into X an array of two, 13 00:01:05,730 --> 00:01:07,200 three, four or five in the more. 14 00:01:10,260 --> 00:01:13,450 And then finally, you can provide default values. 15 00:01:14,820 --> 00:01:17,940 So in this case, I only have one element in the array. 16 00:01:19,090 --> 00:01:27,010 So when I say X equals three more, it gets replaced by the one the Y gets for because that's the default. 17 00:01:28,050 --> 00:01:30,150 So let's take a look at a few examples of this. 18 00:01:32,550 --> 00:01:37,980 All right, so let's kind of walk through the example so the destruction requires variables, you can 19 00:01:38,460 --> 00:01:43,230 declare them like I did on the slides when you use them or you can declare them separately. 20 00:01:43,260 --> 00:01:50,580 So I can say let X, Y and we'll have a couple of variables. 21 00:01:51,240 --> 00:02:01,710 And then I could say X, comma Y equals to come forward comma six come eight or it doesn't have to be 22 00:02:01,710 --> 00:02:03,850 a literal it can be a variable itself, of course. 23 00:02:05,850 --> 00:02:22,060 So let's make a variable what my array equals and then I can say my array and then console that log 24 00:02:22,060 --> 00:02:29,850 and let me use the template format here, the string template and I say X equals. 25 00:02:34,320 --> 00:02:36,330 Y equals. 26 00:02:41,320 --> 00:02:41,680 All right. 27 00:02:44,590 --> 00:02:44,920 So it's. 28 00:02:46,900 --> 00:02:48,430 So access to an Ys for. 29 00:02:49,680 --> 00:03:01,830 Which is fine if we continue out with this A, B, C, D and. 30 00:03:05,050 --> 00:03:16,740 Just copy this with the camera, so say why A, B, C, D, so its search for the Y. 31 00:03:21,330 --> 00:03:25,770 So we don't want to change this one, I'm hitting up three to go between, so this one's going to be 32 00:03:25,770 --> 00:03:40,680 A, A, B, B, C, C, the D, and of course, we have to declare our variables, otherwise it wouldn't 33 00:03:40,680 --> 00:03:41,390 work very well. 34 00:03:42,510 --> 00:03:48,660 So we'll say, what A, but B, let's see 35 00:03:51,570 --> 00:03:51,780 what. 36 00:03:53,640 --> 00:03:55,710 And so why would a car like this are undefined. 37 00:03:57,600 --> 00:03:59,210 All right, let's see what happens. 38 00:04:02,880 --> 00:04:09,420 We've got two, four, six, eight, C is undefined and DS undefined because it wasn't in the original 39 00:04:09,420 --> 00:04:23,790 thing, but if I said C equals three and D equals four, then then have a value because there's a default. 40 00:04:28,600 --> 00:04:30,610 So these three ideas for in this case. 41 00:04:32,770 --> 00:04:38,440 All right, so now let's just look at the more operator, the rest operator, I'm sorry. 42 00:04:40,910 --> 00:04:42,910 So we want to do is to find an array. 43 00:04:50,110 --> 00:05:04,410 First, to put the values in and then we will say XCOM DataDot, other Arae equals my array 44 00:05:07,090 --> 00:05:09,130 and then let's copy this 45 00:05:12,460 --> 00:05:13,420 and. 46 00:05:17,020 --> 00:05:17,860 Will say. 47 00:05:29,360 --> 00:05:30,950 All right, let's run that. 48 00:05:34,920 --> 00:05:37,470 So this year, our original rate was two, four, six, eight. 49 00:05:37,500 --> 00:05:44,430 So the X got the two and the other Ray got four, six, eight, six covers of Ray destruction. 50 00:05:44,460 --> 00:05:48,780 We're going to be looking at this more later with objects as well as what, the spread operator. 51 00:05:49,590 --> 00:05:55,430 So in the meantime, practice using this and it'll start to make sense to you after a while.