1 00:00:01,510 --> 00:00:06,820 Welcome back, my friends, to another lecturer in today's lecture, are we going to talk about S8 or 2 00:00:06,820 --> 00:00:08,690 ECMAScript 2017? 3 00:00:09,190 --> 00:00:16,780 So last time we covered S7 in now the time has come to cover these S8 features to the day. 4 00:00:16,780 --> 00:00:18,100 We're going to talk about a couple of things. 5 00:00:18,520 --> 00:00:24,370 We got to talk about pets start pet and trailing commas in function parameter lists and calls. 6 00:00:24,850 --> 00:00:29,440 What a long name for for it will be object values. 7 00:00:29,440 --> 00:00:31,750 Object entries in object keys. 8 00:00:31,750 --> 00:00:36,980 Now object is not new, but I didn't never told you about this one, so it's my fault. 9 00:00:37,000 --> 00:00:39,780 OK, so let's start with this. 10 00:00:40,120 --> 00:00:42,520 So these are two string methods. 11 00:00:42,940 --> 00:00:48,940 The first one that start and pattern for that, let's create first. 12 00:00:52,200 --> 00:00:55,260 Name and let's call it and this guy. 13 00:00:57,450 --> 00:00:59,940 Counsel, whoops, come on. 14 00:01:01,790 --> 00:01:07,790 Console dialogue, we're going to cause a lot of the first name right away and let's go back here. 15 00:01:08,960 --> 00:01:09,980 Let's see what's happening. 16 00:01:10,010 --> 00:01:11,000 You don't need to see this. 17 00:01:11,060 --> 00:01:12,280 So and these they're right. 18 00:01:12,710 --> 00:01:13,790 So we control a lot. 19 00:01:14,150 --> 00:01:20,300 So what we can do now, I'm just saying console the log and I'm going to see a first name. 20 00:01:20,310 --> 00:01:21,320 Not bad. 21 00:01:21,680 --> 00:01:22,280 Come on. 22 00:01:23,090 --> 00:01:24,110 Bad start. 23 00:01:26,170 --> 00:01:33,970 And because this is a method we need to use that curly brackets, I'm sorry, not brackets and let's 24 00:01:33,970 --> 00:01:35,200 say at 15, dear. 25 00:01:36,250 --> 00:01:37,720 So what you think will happen. 26 00:01:39,310 --> 00:01:40,060 So there you go. 27 00:01:40,060 --> 00:01:46,210 The and the is shift to the right for 11 spaces. 28 00:01:46,840 --> 00:01:49,800 When I say 11, somebody will ask me, Will, there is a 15. 29 00:01:50,200 --> 00:01:52,570 Well, 15 is our number. 30 00:01:52,580 --> 00:01:55,690 But you need to also count this Andy character. 31 00:01:55,690 --> 00:02:02,040 So we have two for so 15 minus four. 32 00:02:02,170 --> 00:02:03,730 That gives you 11. 33 00:02:04,000 --> 00:02:08,020 So the 11 characters or 11 spaces will be added to this string. 34 00:02:08,260 --> 00:02:10,330 And this is good for indentation, right? 35 00:02:10,570 --> 00:02:13,400 It's a very good for making padding. 36 00:02:13,420 --> 00:02:16,550 So adding padding to the string on left and on the right. 37 00:02:16,840 --> 00:02:18,550 So we have this for the left. 38 00:02:20,380 --> 00:02:22,090 So let me just do it like this. 39 00:02:23,920 --> 00:02:25,840 Bad stark. 40 00:02:27,510 --> 00:02:28,290 To add. 41 00:02:30,420 --> 00:02:39,090 Batting to the left, right, and I'm just going to copy this, but I'm not going to need everything 42 00:02:39,090 --> 00:02:40,820 here, I don't need Yandi anymore. 43 00:02:42,540 --> 00:02:47,820 So Pat and yeah, let's say to add padding to the right. 44 00:02:50,300 --> 00:02:52,580 Off the string. 45 00:02:53,840 --> 00:02:54,230 But. 46 00:02:55,830 --> 00:02:56,400 Very good. 47 00:02:56,860 --> 00:02:58,200 Now, Pat and. 48 00:03:01,840 --> 00:03:02,620 It's been like this. 49 00:03:04,250 --> 00:03:07,680 There you go, but you don't see it here, right? 50 00:03:08,330 --> 00:03:10,900 You don't see it, but if I do this, yeah, you will see it. 51 00:03:11,120 --> 00:03:15,560 So that's why I can say I can concatenate with DOT there. 52 00:03:15,890 --> 00:03:16,490 There you go. 53 00:03:17,880 --> 00:03:20,340 So if I put it here like 10. 54 00:03:21,360 --> 00:03:22,700 That will move, right? 55 00:03:23,190 --> 00:03:24,960 So it's adding actually six. 56 00:03:26,530 --> 00:03:35,030 Right, it's not 10, one, two, three, four, five, six in here was 11, right? 57 00:03:35,260 --> 00:03:45,480 One, two, three, four, five, six, seven, eight, nine, 10, 11. 58 00:03:46,810 --> 00:03:49,510 Wow, that was super tired for me. 59 00:03:49,990 --> 00:03:54,760 I just I didn't expect to be so, so tired for me. 60 00:03:54,940 --> 00:03:58,930 OK, so we have done this to so bad start and end. 61 00:03:59,380 --> 00:04:04,390 Now what we need to continue is to use these trailing commas and in function parameter released and 62 00:04:04,390 --> 00:04:04,720 calls. 63 00:04:04,840 --> 00:04:08,230 So listen, you don't have to worry about this part and. 64 00:04:09,410 --> 00:04:12,470 It's not nothing but just a synthetical sure, right. 65 00:04:12,680 --> 00:04:14,100 So what we can do now? 66 00:04:14,240 --> 00:04:18,810 I'm going to create a function and we're going to test this inside a function because it's saying, 67 00:04:18,830 --> 00:04:20,960 whoops, parameter list. 68 00:04:20,960 --> 00:04:21,200 Right. 69 00:04:21,410 --> 00:04:25,010 So where we do have parameter list, well, inside a function. 70 00:04:25,220 --> 00:04:27,780 So const comma function. 71 00:04:27,810 --> 00:04:28,270 Wow. 72 00:04:28,280 --> 00:04:32,420 This is the first time that somebody's saying comma function and that is going to be me. 73 00:04:32,450 --> 00:04:43,850 OK, so I'm going to say A, B, C, D and let's create here a narrow function and cancel the log a, 74 00:04:44,030 --> 00:04:45,260 B that's it. 75 00:04:45,710 --> 00:04:48,150 Because of the long and B and call it from here. 76 00:04:48,530 --> 00:04:49,970 So you're going to say. 77 00:04:51,070 --> 00:04:51,970 Karma function. 78 00:04:53,460 --> 00:04:56,830 And just pass one, two, three, four. 79 00:04:57,720 --> 00:04:58,470 So we have four. 80 00:04:58,500 --> 00:04:59,190 Yes, we do. 81 00:05:00,030 --> 00:05:02,630 OK, now I do have back one and two. 82 00:05:03,450 --> 00:05:05,110 So what's the idea here? 83 00:05:05,570 --> 00:05:10,710 We trailing commas, in fact, in a function parameter list. 84 00:05:11,180 --> 00:05:12,390 Let me just copy this one. 85 00:05:12,900 --> 00:05:14,280 So you know what's happening there. 86 00:05:14,760 --> 00:05:21,870 Well, imagine if we add here a comma and if we save it, then it will not change the output. 87 00:05:22,410 --> 00:05:24,150 And why this is useful? 88 00:05:24,180 --> 00:05:25,220 Well, there are two benefits. 89 00:05:25,470 --> 00:05:32,640 First, the rearranging of items is very simple because you don't have to add or remove commas if the 90 00:05:32,640 --> 00:05:35,370 last item changes its position. 91 00:05:35,790 --> 00:05:41,640 Now, this might confuse to you, but imagine here that we do have like a lot of parameter lists, a 92 00:05:41,640 --> 00:05:42,060 big one. 93 00:05:42,480 --> 00:05:47,820 And instead of the in one line what the developers are doing, not me. 94 00:05:48,750 --> 00:05:53,370 So they're doing this same as we do with objects, right. 95 00:05:55,320 --> 00:05:55,660 Good. 96 00:05:56,550 --> 00:06:04,320 So now, instead of thinking about rearranging items and we don't have to remove her at commas at the 97 00:06:04,320 --> 00:06:10,870 end because you want to move this one on top here, but the comma is going to stay there, right? 98 00:06:10,890 --> 00:06:12,890 It's not going to mess around with the coat. 99 00:06:13,110 --> 00:06:18,510 So that is why that is one of these useful benefits. 100 00:06:19,380 --> 00:06:20,730 It's not much, to be honest. 101 00:06:21,000 --> 00:06:26,280 The second it helps a version control system with tracking which what actually change. 102 00:06:26,370 --> 00:06:31,950 So this probably does it make sense right now? 103 00:06:32,130 --> 00:06:38,250 The last part is that it helps a version control systems with tracking what actually change. 104 00:06:38,550 --> 00:06:41,040 And I'm going to just show it to you here. 105 00:06:44,400 --> 00:06:48,490 In common, because we don't need this to run, it's not it's not going to run. 106 00:06:48,840 --> 00:06:54,480 So here I'm going to say food and we change this. 107 00:06:55,520 --> 00:07:08,990 From so I'm going to say from two, yeah, two, this is let's hear Essabar, right? 108 00:07:09,860 --> 00:07:13,760 And but you don't you don't need to think about this too much. 109 00:07:13,760 --> 00:07:14,020 Right. 110 00:07:14,270 --> 00:07:17,660 And it's not even something that is pleasant for explaining. 111 00:07:17,900 --> 00:07:18,710 You're not going to see much. 112 00:07:18,710 --> 00:07:23,440 But just make sure that even if you put it here, comma, it will not change the apple. 113 00:07:23,660 --> 00:07:25,430 What will happen if we put a comma here? 114 00:07:25,730 --> 00:07:26,090 Right. 115 00:07:27,500 --> 00:07:32,480 There is not going to change up because parameter lists and calls, because this is what we are calling 116 00:07:32,480 --> 00:07:32,870 a function. 117 00:07:32,900 --> 00:07:34,530 OK, but it's never a good idea. 118 00:07:34,530 --> 00:07:35,690 I never put a comma there. 119 00:07:36,460 --> 00:07:37,320 I'm not going to do that. 120 00:07:37,400 --> 00:07:43,250 OK, but here you can get a new if you want and you don't have to worry about the commas. 121 00:07:43,430 --> 00:07:46,880 OK, this was super weird for explanation. 122 00:07:47,600 --> 00:07:48,010 Nice. 123 00:07:48,200 --> 00:07:49,070 Forget about this. 124 00:07:49,070 --> 00:07:57,950 Number three, now we move to number four, a number for a very, very good right object values, object 125 00:07:57,950 --> 00:07:59,150 entries and object keys. 126 00:07:59,180 --> 00:08:01,610 I'm going to start with object keys first. 127 00:08:01,610 --> 00:08:05,600 I'm not going to say four here, but I'm going to say object. 128 00:08:10,590 --> 00:08:13,380 So why do we need somebody will say, why do we need object keys? 129 00:08:13,680 --> 00:08:16,020 Well, let's first create one. 130 00:08:17,970 --> 00:08:25,170 Object call, user object, and inside this user object, we're going to have a couple of user users, 131 00:08:25,920 --> 00:08:27,810 so user one, right? 132 00:08:28,230 --> 00:08:30,180 So this will be just thumb. 133 00:08:31,290 --> 00:08:33,830 Then we're going to have user two. 134 00:08:34,740 --> 00:08:36,470 It will be Andy. 135 00:08:38,220 --> 00:08:39,930 Come on, Andy. 136 00:08:39,930 --> 00:08:40,830 Don't mess with me. 137 00:08:41,400 --> 00:08:42,450 User three. 138 00:08:43,430 --> 00:08:53,930 It will be Sarah and user four, it will be Angelina and put a breathing space there, why do you doing 139 00:08:53,930 --> 00:08:54,320 this? 140 00:08:56,210 --> 00:08:56,500 Good. 141 00:08:57,320 --> 00:08:58,480 And there you go. 142 00:08:58,490 --> 00:09:06,170 Now we have our object now object which is used when we want to loop through this object, as we loop 143 00:09:06,170 --> 00:09:12,560 through the arrays using the foreach or Matmata, because we used it for each Matmata to other methods 144 00:09:13,010 --> 00:09:13,730 for arrays. 145 00:09:13,730 --> 00:09:16,810 But we can't use it on objects in this object. 146 00:09:16,880 --> 00:09:21,950 This allows us so to that to use that functionality on top of the objects. 147 00:09:21,980 --> 00:09:23,510 OK, let me show you to this one. 148 00:09:24,650 --> 00:09:30,860 Now we need to say object keys just like this, and it will change a little bit color because this is 149 00:09:30,860 --> 00:09:34,520 a reserved word user object. 150 00:09:34,530 --> 00:09:36,920 We need to pass the entire object here. 151 00:09:37,070 --> 00:09:37,470 Good. 152 00:09:38,150 --> 00:09:44,150 Now I'm going to say for each and inside, I do have access to the key. 153 00:09:44,200 --> 00:09:45,860 What is going to put that one in bracket? 154 00:09:48,870 --> 00:09:50,970 OK, so if Consul Log. 155 00:09:52,340 --> 00:09:56,730 And I'm going to say key, and here I'm going to pass the key here, right? 156 00:09:57,440 --> 00:10:02,980 But that will give me this user one user to user three on each and every loop here. 157 00:10:03,410 --> 00:10:04,770 But what about the value? 158 00:10:04,800 --> 00:10:06,850 So these are key value pairs. 159 00:10:07,010 --> 00:10:09,880 Well, the value we can just get it like this. 160 00:10:11,660 --> 00:10:13,730 You don't have to type this one if you don't want it. 161 00:10:14,150 --> 00:10:17,440 But just it's going to make more sense like this. 162 00:10:17,600 --> 00:10:24,320 So the value we can grab it if you use a user object and we pass the key. 163 00:10:26,370 --> 00:10:30,160 OK, let's see what this will come up to. 164 00:10:30,660 --> 00:10:34,180 So this should have their karma. 165 00:10:34,380 --> 00:10:36,670 Otherwise, it's complaining to us. 166 00:10:37,300 --> 00:10:38,670 OK, so save it. 167 00:10:39,150 --> 00:10:39,680 There you go. 168 00:10:39,690 --> 00:10:46,320 We have key user one value, Tom, key user to value and the user three. 169 00:10:46,320 --> 00:10:48,750 Sarah four will be Angelena. 170 00:10:49,200 --> 00:10:54,240 Now, you know how you can loop through objects like they're on the rate and that. 171 00:10:55,830 --> 00:11:00,720 Object that keys, I'm just going to write this for you guys so you can understand it. 172 00:11:00,720 --> 00:11:08,370 So it's keys, not key is used when we want to loop through. 173 00:11:10,670 --> 00:11:11,450 Objects. 174 00:11:12,830 --> 00:11:21,120 As they are arrested and now, because I don't have enough space, I'm just going to put it here, OK? 175 00:11:21,680 --> 00:11:22,330 Satisfied? 176 00:11:22,520 --> 00:11:22,970 Nice. 177 00:11:23,870 --> 00:11:25,130 What about the number? 178 00:11:25,970 --> 00:11:29,270 Let me just grab this two number for a number five. 179 00:11:31,850 --> 00:11:38,990 And number five, so I have a user object values and object entries, so these two features makes our 180 00:11:38,990 --> 00:11:40,790 life even more easily easier. 181 00:11:40,970 --> 00:11:42,290 We don't have to do this anymore. 182 00:11:42,320 --> 00:11:43,920 OK, so what we can do. 183 00:11:44,420 --> 00:11:47,890 So let's start with user and sorry, object entry. 184 00:11:48,050 --> 00:11:57,050 So object entries will give back an array from your user object with all the entries you can get. 185 00:11:58,070 --> 00:12:04,400 OK, let me just show it to you, this one, because it's super confusing, I know, so we need to say 186 00:12:04,400 --> 00:12:13,880 object and trees in inside, we just plug the user object and we say for each there and I'm just going 187 00:12:13,880 --> 00:12:15,080 to use the key word entry here. 188 00:12:15,080 --> 00:12:16,250 You can use whatever you want. 189 00:12:17,940 --> 00:12:19,280 We already know this things. 190 00:12:19,550 --> 00:12:26,120 So Konza log the entry and let's see what's happening there. 191 00:12:27,290 --> 00:12:29,450 Cannot convert undefined null object. 192 00:12:29,460 --> 00:12:30,590 What's happening here? 193 00:12:30,600 --> 00:12:31,500 I have no idea. 194 00:12:31,820 --> 00:12:34,460 So this is happening. 195 00:12:36,830 --> 00:12:39,160 You should say entry's not something bad. 196 00:12:41,070 --> 00:12:41,580 Save it. 197 00:12:42,390 --> 00:12:43,390 There you go. 198 00:12:43,650 --> 00:12:47,630 Now you have four arrays with two items, four arrays. 199 00:12:47,790 --> 00:12:52,260 So this will give us back an array from our user object, right. 200 00:12:52,830 --> 00:12:53,220 So. 201 00:12:55,610 --> 00:13:02,540 This is actually entries here, not confusing this values there, so this 202 00:13:05,330 --> 00:13:08,780 will give us an array. 203 00:13:13,200 --> 00:13:13,770 Of what? 204 00:13:14,930 --> 00:13:16,760 User object. 205 00:13:20,600 --> 00:13:28,550 Object key value pairs, because we have different key value pairs here, we have four, right? 206 00:13:29,000 --> 00:13:31,400 So if we look if we cancel out the object. 207 00:13:33,790 --> 00:13:42,990 The user object right, there you go, the user object is like this, and now we have one. 208 00:13:43,000 --> 00:13:51,730 How many here you see property and value you see for then we have a four thou four arrays with two items. 209 00:13:52,420 --> 00:13:55,390 So that is about the user object entries. 210 00:13:55,390 --> 00:13:57,610 And now we need object values. 211 00:13:57,850 --> 00:14:02,470 So the object values will give us the value back of each object property. 212 00:14:02,620 --> 00:14:05,110 So it's not going to give this key value pair to us. 213 00:14:05,590 --> 00:14:07,420 It's going to give us just a value. 214 00:14:07,810 --> 00:14:08,160 Right. 215 00:14:08,320 --> 00:14:10,600 And that is something where something very useful. 216 00:14:10,780 --> 00:14:13,330 So I'm going to say object, not values. 217 00:14:14,920 --> 00:14:24,220 And inside I'm going to plug the user object and I'm going to say for each so I can say value doesn't 218 00:14:24,220 --> 00:14:25,390 matter what you want to say here. 219 00:14:25,390 --> 00:14:27,570 If you want to say something else, you can do. 220 00:14:27,850 --> 00:14:29,350 And I'm going to say Kanza log. 221 00:14:30,630 --> 00:14:31,140 Value. 222 00:14:32,060 --> 00:14:36,680 And I don't know why I'm not printing this in one line, it's going to work, right. 223 00:14:38,380 --> 00:14:38,980 Let's see. 224 00:14:41,970 --> 00:14:43,370 Very good. 225 00:14:45,740 --> 00:14:48,440 There you go, I have Dormandy and Angelina. 226 00:14:48,830 --> 00:14:59,000 Those are the values from the properties, so these so object values will give back the values of the 227 00:14:59,330 --> 00:15:01,490 object properties. 228 00:15:03,670 --> 00:15:08,350 These are the properties on the left side and these are the values, key or keys doesn't matter. 229 00:15:09,760 --> 00:15:12,200 Keys nice. 230 00:15:13,060 --> 00:15:13,660 There you go. 231 00:15:13,690 --> 00:15:15,190 Now, you know all of it. 232 00:15:15,520 --> 00:15:20,350 And I have some very interesting exercises for you. 233 00:15:20,620 --> 00:15:21,010 Right. 234 00:15:21,080 --> 00:15:24,670 Make sure that you do them in for the for the previous lecture. 235 00:15:24,700 --> 00:15:32,840 So we have at Pat Start, Pat End and we have these trailing commas, what you can forget a little bit. 236 00:15:33,100 --> 00:15:37,830 So in simple words, even if you add comma there, it will not throw you an error. 237 00:15:37,840 --> 00:15:38,290 That's it. 238 00:15:38,470 --> 00:15:40,510 Even if you had to come on there and. 239 00:15:41,590 --> 00:15:51,640 Then we do object that keys so we can lub we can loop through the through the objects, same as we did 240 00:15:51,640 --> 00:15:52,240 with Arae. 241 00:15:52,330 --> 00:15:57,700 So we before, if we don't use this, we will not be able to use this for each or Matmata. 242 00:15:57,700 --> 00:15:57,950 Right. 243 00:15:58,270 --> 00:16:00,550 Object entries will give us back. 244 00:16:01,580 --> 00:16:08,900 Properties and values in a Inari in one array in each time will give us back an array, each loop will 245 00:16:08,900 --> 00:16:14,750 give us back on the ring and the last time object values will give us only the value of the properties 246 00:16:14,750 --> 00:16:15,920 of the keys on left side. 247 00:16:16,190 --> 00:16:16,510 Right. 248 00:16:17,510 --> 00:16:19,270 These from the object. 249 00:16:19,640 --> 00:16:21,350 OK, so there you go. 250 00:16:21,350 --> 00:16:30,410 Now you know about S8 feature features and there is a one very big feature that I would talk about in 251 00:16:30,410 --> 00:16:31,980 the next lecture. 252 00:16:32,000 --> 00:16:39,770 Make sure you watch this lecture because that lecture, because it will be super, super cool and it 253 00:16:39,770 --> 00:16:41,440 will be about async awake. 254 00:16:42,530 --> 00:16:45,170 So that is one of the biggest feature of S8. 255 00:16:45,170 --> 00:16:45,500 Right. 256 00:16:45,770 --> 00:16:47,210 And it's built on promises. 257 00:16:48,370 --> 00:16:51,430 On top of promises, so, yeah, we know what you need to know. 258 00:16:51,490 --> 00:16:53,510 Promises as well in order to tackle that one. 259 00:16:53,710 --> 00:16:57,070 So seeing that one and take care.