1 00:00:01,470 --> 00:00:02,010 Welcome back. 2 00:00:02,040 --> 00:00:06,780 Today, we're going to discuss about iOS nine and what is the most important feature of this. 3 00:00:07,080 --> 00:00:13,170 So there are more features, but this is the in this version in iOS nine or 2018, the most important 4 00:00:13,170 --> 00:00:15,950 feature is object spread operator. 5 00:00:15,990 --> 00:00:17,430 OK, create any file that you want. 6 00:00:18,300 --> 00:00:25,770 So here I'm going to create an object cast in this object, by the way, it will hold the name of the 7 00:00:25,770 --> 00:00:30,600 car and the amount of cars we have in stock, for example, Tesla. 8 00:00:34,170 --> 00:00:42,250 And Tesla will have 40, then I will have Ram, Ram will have 15 and they will have four with 45. 9 00:00:42,420 --> 00:00:42,810 Cool. 10 00:00:43,140 --> 00:00:47,540 Now what I can do here, the sprint operator in year six was available for the. 11 00:00:47,940 --> 00:00:49,740 But we can use it here on the object. 12 00:00:49,980 --> 00:00:51,390 So I'm going to create consed here. 13 00:00:51,510 --> 00:00:59,820 Curly brackets, BMW, the first one, the first item from the cars and I can use comma here three dots 14 00:01:00,300 --> 00:01:04,100 and I can say a rest and that will be stored in the cars. 15 00:01:04,350 --> 00:01:04,730 Nice. 16 00:01:06,210 --> 00:01:08,900 So how is this is working. 17 00:01:09,330 --> 00:01:19,020 Now if I copy this part here and if I go back to the console and if I sit down and enter nothing will 18 00:01:19,020 --> 00:01:19,380 happen. 19 00:01:19,380 --> 00:01:21,800 But let's now access the BMW. 20 00:01:22,110 --> 00:01:22,500 Here it is. 21 00:01:22,500 --> 00:01:25,670 The BMW have 50 cars in stock in. 22 00:01:25,680 --> 00:01:26,610 What about the rest? 23 00:01:26,970 --> 00:01:32,850 The rest will return as an object with the rest of the items from that car's object. 24 00:01:33,300 --> 00:01:34,200 So how cool is this? 25 00:01:34,590 --> 00:01:34,980 Right. 26 00:01:35,610 --> 00:01:36,540 This is very nice. 27 00:01:36,540 --> 00:01:43,430 And and we can use it now before as I say, as I said, that we can use it for an array. 28 00:01:43,440 --> 00:01:47,940 For example, let array here and I will create an array with four items. 29 00:01:48,240 --> 00:01:53,750 One sorry, instead of one, I'm typing two, one, two, three, four and five. 30 00:01:54,120 --> 00:01:54,470 Right. 31 00:01:54,600 --> 00:01:59,180 And let's create a function that will create that will calculate the average of this array. 32 00:01:59,400 --> 00:02:12,090 So function eight KBG array and that function actually will have a will have how many parameters. 33 00:02:12,330 --> 00:02:13,620 So we have five parameters here. 34 00:02:13,650 --> 00:02:20,220 Amy C, d, e right now here. 35 00:02:20,220 --> 00:02:21,180 I'm just going to return. 36 00:02:24,820 --> 00:02:35,560 Return the A plus B plus C plus the plus E, and after that I'm going to see Ouray the length because 37 00:02:35,560 --> 00:02:41,320 I want to grab the length and I want to divide the sum of this array here of these parameters. 38 00:02:41,440 --> 00:02:41,830 Nice. 39 00:02:42,670 --> 00:02:44,740 So we can call this EVGA. 40 00:02:45,010 --> 00:02:49,160 All right here with dot, dot, dot array. 41 00:02:49,480 --> 00:02:49,840 Right. 42 00:02:50,170 --> 00:02:52,420 So we can use the spread operator over there. 43 00:02:52,450 --> 00:02:53,290 Let's call it here. 44 00:02:53,860 --> 00:02:54,640 Let's see what's happening. 45 00:02:55,450 --> 00:02:56,950 I'm going to refresh here the browser. 46 00:02:57,970 --> 00:02:59,100 I'm going to piece this one here. 47 00:02:59,410 --> 00:03:00,580 I'm going to do it like that. 48 00:03:00,580 --> 00:03:03,850 And the result, the output will be three. 49 00:03:04,360 --> 00:03:10,800 Right, because this will give us 15 divided by five, and that is actually three. 50 00:03:10,930 --> 00:03:15,970 So that is how we use this feature in a rate of forty eight. 51 00:03:16,450 --> 00:03:18,460 Now that is pretty much it. 52 00:03:18,460 --> 00:03:23,650 But I will, I will create one more function here and I will use the same logic for this one. 53 00:03:25,150 --> 00:03:32,140 But I'm going to create a function to calculate the actual not look like I'm going to print out this 54 00:03:32,140 --> 00:03:32,310 one. 55 00:03:32,350 --> 00:03:36,480 So do use the again the object spread operator. 56 00:03:36,730 --> 00:03:38,080 So I'm going to see object. 57 00:03:38,080 --> 00:03:43,180 The name of the function will be object spread and it will take name one and name two. 58 00:03:43,630 --> 00:03:48,990 So name one is actually going to be the name of any of this that you want. 59 00:03:49,300 --> 00:03:50,640 So objects Fred. 60 00:03:51,190 --> 00:03:56,620 Next in here, what I can do, I can print on the log a name one. 61 00:03:56,770 --> 00:03:57,250 Right. 62 00:03:58,000 --> 00:03:59,410 And cancel that log. 63 00:04:00,040 --> 00:04:07,180 The need to know, OK, we have done this so only we need to call this outside. 64 00:04:07,570 --> 00:04:16,300 So we need to call this function and we can pass the BMW right in the second parameter. 65 00:04:16,600 --> 00:04:19,240 He's we can call it the rest. 66 00:04:24,150 --> 00:04:31,290 Let's save it, and what we need to do right now is I need to comment at this point here, actually 67 00:04:32,610 --> 00:04:38,040 this part here, and I want to copy the entire thing because I want to use the object again because 68 00:04:38,040 --> 00:04:39,500 I refreshed it's nothing. 69 00:04:39,510 --> 00:04:41,390 It's not there in the console lot. 70 00:04:41,610 --> 00:04:43,050 So I'm just going to hit enter. 71 00:04:43,290 --> 00:04:44,000 And here it is. 72 00:04:44,370 --> 00:04:51,720 I do have the 15 and I do have the object of desire for RAM and Tesla. 73 00:04:51,870 --> 00:04:52,250 Right. 74 00:04:52,560 --> 00:04:57,150 So that is how we can use the spread operator over objects. 75 00:04:57,330 --> 00:04:57,710 Right. 76 00:04:57,940 --> 00:04:58,740 This super cool. 77 00:04:58,950 --> 00:04:59,850 Super interesting. 78 00:04:59,850 --> 00:05:06,120 And I hope you enjoyed this lecture because now you know how to use the spread operator over objects, 79 00:05:06,430 --> 00:05:08,130 and that is super cool. 80 00:05:08,160 --> 00:05:09,730 So I will see you in the next lecture. 81 00:05:09,780 --> 00:05:10,620 Enjoy.