1 00:00:00,830 --> 00:00:01,940 Welcome back, ladies and gentlemen. 2 00:00:01,970 --> 00:00:08,180 Today's lecture will be super short, but we will talk about new feature in ECMAScript nine, and that 3 00:00:08,180 --> 00:00:09,780 is ECMAScript 2018. 4 00:00:09,800 --> 00:00:12,800 So this feature was released in 2018. 5 00:00:12,860 --> 00:00:16,700 And you should be happy because we are progressing very, very fast. 6 00:00:16,970 --> 00:00:19,490 And, yeah, you should be happy with your progress. 7 00:00:19,640 --> 00:00:21,430 Now we're going to talk about spread operator. 8 00:00:21,620 --> 00:00:24,600 We did spread operator honourees. 9 00:00:24,770 --> 00:00:25,130 Right. 10 00:00:25,460 --> 00:00:30,650 Let me just remind you before we start to talk about Sprint operator on objects. 11 00:00:30,800 --> 00:00:37,040 So I'm going to say here a spread operator on arrays is six. 12 00:00:37,160 --> 00:00:37,680 Nice. 13 00:00:38,240 --> 00:00:39,880 So what this was is six feature. 14 00:00:40,160 --> 00:00:47,350 So I'm going to create an array called Cars in stock and I'm just going to let's put a higher rate. 15 00:00:47,360 --> 00:00:50,440 A lot of big descriptive name in here. 16 00:00:50,450 --> 00:00:53,900 I'm going to pass some random numbers. 17 00:00:54,090 --> 00:00:56,240 How many cars we have in stock. 18 00:00:56,510 --> 00:00:56,900 Right. 19 00:00:57,050 --> 00:00:59,100 So how many cars are there in the yard? 20 00:00:59,330 --> 00:01:04,450 So 18 here, then 33, then 88 and seventy nine. 21 00:01:04,460 --> 00:01:05,750 You can put any numbers you want. 22 00:01:06,080 --> 00:01:14,180 OK, now let's create a function that will calculate and return back the whole amount of these elements. 23 00:01:14,330 --> 00:01:18,170 So cost Colque in stock. 24 00:01:18,180 --> 00:01:21,850 You can call this the function, anything you want. 25 00:01:21,860 --> 00:01:22,180 Right. 26 00:01:22,580 --> 00:01:27,260 And let's put here A, B, C, D, E and F. 27 00:01:28,290 --> 00:01:34,260 How I know this well, because we have this amount of elements here in the array. 28 00:01:34,590 --> 00:01:40,200 OK, so let some or some it doesn't matter. 29 00:01:40,350 --> 00:01:50,500 A plus B, C, D, E, plus F, and we return to some. 30 00:01:50,640 --> 00:01:54,950 Now let's use the spread operator so called a function. 31 00:01:56,040 --> 00:02:00,930 So how we do this const result you can just cancel. 32 00:02:00,960 --> 00:02:08,190 It looks great, but I'm just as a cog in stock and I'm going to pass here using the spread operator, 33 00:02:08,400 --> 00:02:09,000 the array. 34 00:02:09,780 --> 00:02:13,830 Now the last thing we need to do, cancel that log. 35 00:02:14,160 --> 00:02:14,880 The result. 36 00:02:16,990 --> 00:02:30,850 Total number of cars in the yard as a here, we're going to pass the result, not return result where 37 00:02:30,850 --> 00:02:35,770 we get save it, make sure the electorate linking your index file. 38 00:02:37,900 --> 00:02:44,460 The total number is fifty seven nights, so if you manually do this, you will see that is 350. 39 00:02:44,830 --> 00:02:49,010 So if you manually at each and every of this, you will get three fifty seven. 40 00:02:49,040 --> 00:02:51,070 Now, what a spread operator is doing. 41 00:02:51,250 --> 00:02:57,490 The spread overeagerness doing it spread all of the three elements over the parameter release of this 42 00:02:57,490 --> 00:02:57,940 function. 43 00:02:57,940 --> 00:02:58,240 Right. 44 00:02:58,900 --> 00:02:59,760 How cool is this? 45 00:03:00,040 --> 00:03:01,630 This is super, super useful. 46 00:03:01,630 --> 00:03:02,800 We can do it one by one. 47 00:03:02,800 --> 00:03:07,080 We can pass in multiple here parameters like 125, 14, 18. 48 00:03:07,090 --> 00:03:12,350 But that's not the point why we can why we need to do that when we have the spread operator. 49 00:03:12,790 --> 00:03:14,210 Now, that is pretty much it. 50 00:03:14,530 --> 00:03:19,930 So the second thing is to use spread operator. 51 00:03:21,830 --> 00:03:25,110 On objects, so this is the new thing. 52 00:03:25,130 --> 00:03:29,810 So this was just to remind you how this was done in year six. 53 00:03:30,590 --> 00:03:37,010 Now let's create here an object concept called cars in stock. 54 00:03:37,880 --> 00:03:41,090 And you can say Olby for object or object. 55 00:03:41,690 --> 00:03:42,110 Right. 56 00:03:42,410 --> 00:04:00,350 And this object will have BMW or BMW beefing Audi or Audi 16, Mercedes or Terrasse 24, for example. 57 00:04:00,500 --> 00:04:01,490 Any numbers you want. 58 00:04:01,760 --> 00:04:04,250 And A for 18. 59 00:04:06,430 --> 00:04:07,300 Very good. 60 00:04:07,750 --> 00:04:10,270 Now, how are we going to use the spread operator here? 61 00:04:10,300 --> 00:04:15,710 Well, let's do this consed BMW, right? 62 00:04:16,300 --> 00:04:21,520 Come on, if I can, Deborah, and then I can use the rest. 63 00:04:22,450 --> 00:04:29,380 Now I'm going to pass here the cars in stock object and that's pretty much it. 64 00:04:29,380 --> 00:04:31,870 But if I save it, you're not going to see any changes here. 65 00:04:32,180 --> 00:04:36,730 OK, but look what is happening now if I can't unlock the BMW. 66 00:04:40,080 --> 00:04:47,710 Now I have 15 or the value that I had in the BMW, cool, so I get the value using the spread operator. 67 00:04:48,090 --> 00:04:51,420 OK, now these three, does that rest? 68 00:04:51,450 --> 00:04:52,830 What, you think it will give it to us? 69 00:04:53,700 --> 00:04:55,410 It will give something like this. 70 00:04:55,410 --> 00:04:56,370 I can say rest. 71 00:04:57,510 --> 00:05:03,840 So it will give us another object containing autistics, Mercedes's and for nice. 72 00:05:04,320 --> 00:05:09,810 So that returns the rest of them as an object with their key value pairs. 73 00:05:10,140 --> 00:05:10,520 Right. 74 00:05:10,830 --> 00:05:13,070 And that is pretty much OK. 75 00:05:13,350 --> 00:05:13,770 So. 76 00:05:14,940 --> 00:05:25,500 We can access this like this, Audy, we can access it by Mercedes's, then we have another, but that 77 00:05:25,500 --> 00:05:27,380 is the power of the spread operator. 78 00:05:27,600 --> 00:05:34,300 So now that you know that you can use it on even on the objects and make sure that you're doing the 79 00:05:34,300 --> 00:05:37,900 your exercise, because they will be pretty much more interesting than this. 80 00:05:37,900 --> 00:05:42,270 So I don't want to reveal everything here because I want you to practice on your own. 81 00:05:42,300 --> 00:05:44,200 OK, that's pretty much it for this lecture. 82 00:05:44,220 --> 00:05:45,690 I see you in the next one.