1 00:00:01,500 --> 00:00:07,000 In this lecture, we're going to cover the most important feature of S8 or ECMAScript, right? 2 00:00:07,260 --> 00:00:12,180 We did talk a little bit about weight, not little bit actually explained the whole process when we 3 00:00:12,180 --> 00:00:13,380 were dealing with promises. 4 00:00:13,380 --> 00:00:18,660 So if you want to go back, you can check those out and you will get clear but clear idea. 5 00:00:18,670 --> 00:00:23,130 But in the future, in the next lecture, I will just mention a little bit more about them. 6 00:00:23,430 --> 00:00:29,430 And so if you haven't watched that one, you can still watch this next one and you will have idea how 7 00:00:29,430 --> 00:00:33,120 we consume promises, because this is nothing, how we write promises. 8 00:00:33,270 --> 00:00:38,370 And in the next lecture, I will not spend a time explaining how we did write the promises. 9 00:00:38,550 --> 00:00:41,270 So that is my recommendation to go back and look. 10 00:00:41,550 --> 00:00:42,450 Now, first things first. 11 00:00:42,780 --> 00:00:49,590 The eight features that were released in 2017 are a couple a few more compared to the first seven. 12 00:00:49,590 --> 00:00:49,830 Right. 13 00:00:49,950 --> 00:00:52,290 In this video, I will just mention the most important ones. 14 00:00:52,590 --> 00:00:56,550 These are the screen functions that start and pat in. 15 00:00:56,790 --> 00:01:01,590 And after that we have object values and object entries before we used object keys. 16 00:01:01,890 --> 00:01:03,270 So I'm going to touch on that one. 17 00:01:03,510 --> 00:01:08,550 So I've opened up here any so you can open up any JavaScript file that you want. 18 00:01:08,550 --> 00:01:10,050 You can name it anyone you want. 19 00:01:10,080 --> 00:01:13,410 I'm not going to give you this one because this is so simple in most of the code. 20 00:01:13,420 --> 00:01:17,820 I'm going to run back to the console here, console console lock in this one. 21 00:01:17,820 --> 00:01:21,080 So it's not going to so it's not going to be something useful here. 22 00:01:21,090 --> 00:01:25,640 No, I'm doing this because it will be easier for me to just write it down and explain it to you. 23 00:01:25,890 --> 00:01:26,850 Now, first things first. 24 00:01:26,970 --> 00:01:29,460 Let's try to count in the console, OK? 25 00:01:30,570 --> 00:01:32,990 I'm going to write a string called Tom. 26 00:01:33,900 --> 00:01:40,340 Now, I'm can I can use on Pad Start and I can add a number here. 27 00:01:40,380 --> 00:01:41,690 So look what he's doing. 28 00:01:42,240 --> 00:01:43,950 So I've had a number. 29 00:01:43,950 --> 00:01:47,460 And actually what it creates creates seven spaces before Tom. 30 00:01:47,760 --> 00:01:49,950 But somebody will ask me why seven spaces. 31 00:01:49,950 --> 00:01:51,450 Because I put ten. 32 00:01:51,570 --> 00:01:54,800 Well, because Tom has three characters, three miners. 33 00:01:54,810 --> 00:01:55,770 Then it will be seven. 34 00:01:56,010 --> 00:01:56,400 Right. 35 00:01:56,610 --> 00:01:58,050 I can use the opposite of this. 36 00:01:58,650 --> 00:02:06,570 It's called pad and and it will give us seven spaces after the storm all together. 37 00:02:06,570 --> 00:02:07,950 They will be ten. 38 00:02:08,190 --> 00:02:08,570 Right. 39 00:02:08,850 --> 00:02:09,990 So don't get confused. 40 00:02:09,990 --> 00:02:14,580 Don't think that here it will at ten spaces now why we used it. 41 00:02:14,590 --> 00:02:24,180 So this is the way that you can actually give a paragraph batting or street batting or anything that 42 00:02:24,180 --> 00:02:25,530 is connected with text a line. 43 00:02:25,680 --> 00:02:26,100 Right. 44 00:02:26,460 --> 00:02:30,930 So that's pretty much about these two bad start at Bannen. 45 00:02:31,350 --> 00:02:31,770 Right. 46 00:02:31,980 --> 00:02:33,020 These two features. 47 00:02:33,330 --> 00:02:36,000 Now, let's go back to the objects now. 48 00:02:36,000 --> 00:02:37,800 The first way that we run, right. 49 00:02:37,830 --> 00:02:39,960 The object was the object key. 50 00:02:40,290 --> 00:02:43,790 And I'm going to write object here and I'm going to say object. 51 00:02:44,010 --> 00:02:47,880 And this object will store first. 52 00:02:47,880 --> 00:02:54,300 I'm going to see a first name and I'm going to say for the first name. 53 00:02:57,670 --> 00:03:08,020 I am going to give here thumb, right for the last name, I will say Cruz and what is your occupation 54 00:03:09,730 --> 00:03:11,160 actor right. 55 00:03:11,200 --> 00:03:15,520 So this is how we write an object before this is a key value pair. 56 00:03:15,520 --> 00:03:21,580 And before we just use we want to look through when you see this is give you that uneasy look, I need 57 00:03:21,580 --> 00:03:23,070 to loop through this object. 58 00:03:23,080 --> 00:03:25,360 I need to get the values, the keys, whatever is there. 59 00:03:25,630 --> 00:03:27,360 But this is not unary. 60 00:03:27,490 --> 00:03:30,450 You can write all of the methods for the area. 61 00:03:30,670 --> 00:03:31,020 Right. 62 00:03:31,180 --> 00:03:36,370 That's why we had some problems in our Berney project that we did. 63 00:03:36,490 --> 00:03:39,550 So we need to convert this back an object to Honoria. 64 00:03:39,760 --> 00:03:41,950 But here there was just something more powerful. 65 00:03:42,370 --> 00:03:45,400 And we can use the object values and object entries. 66 00:03:45,640 --> 00:03:46,540 But first things first. 67 00:03:47,500 --> 00:03:49,960 I want to show you how we write it before. 68 00:03:50,350 --> 00:03:59,490 So I'm going to see here object that keys and here I'm going to pass the entire object that we created 69 00:03:59,510 --> 00:04:01,170 up above right here. 70 00:04:01,180 --> 00:04:03,310 I can use the foreach now method on it. 71 00:04:03,580 --> 00:04:08,500 And here I will say, OK, I have the access of the key and the value up here. 72 00:04:08,740 --> 00:04:09,120 Right. 73 00:04:09,220 --> 00:04:17,210 And I'm going to write the arrow function here and I'm just going to simply Konza lock the key in the 74 00:04:17,260 --> 00:04:19,840 object with that key. 75 00:04:21,310 --> 00:04:23,920 Now, let's copy this one here. 76 00:04:24,770 --> 00:04:28,210 Actually, that's copied in the both of them and put it back here. 77 00:04:28,370 --> 00:04:33,220 Oh, let's first clear this one up and semicolon and hit enter. 78 00:04:33,250 --> 00:04:33,750 Here it is. 79 00:04:33,880 --> 00:04:37,470 So it's going to give me the first name, time, last name, Crucis. 80 00:04:37,480 --> 00:04:40,090 Give me the key value pair. 81 00:04:40,240 --> 00:04:40,650 Right. 82 00:04:41,230 --> 00:04:42,520 But now this. 83 00:04:42,760 --> 00:04:52,810 Even with S8, it can be done a little bit different so we can use so the new way we will grab the values 84 00:04:52,810 --> 00:04:53,920 from each object. 85 00:04:54,070 --> 00:05:02,050 Look at this now here what we can do is we can use the object still value and it's going to be values, 86 00:05:02,050 --> 00:05:02,770 no value. 87 00:05:02,950 --> 00:05:05,380 And I'm going to pass the entire object here. 88 00:05:05,620 --> 00:05:09,880 And again, I can do the foreach, but here I will need only the value. 89 00:05:10,810 --> 00:05:11,230 Right. 90 00:05:12,820 --> 00:05:17,820 And let's write another function and console lock this value. 91 00:05:18,100 --> 00:05:21,130 So what's the difference, somebody will ask. 92 00:05:21,130 --> 00:05:21,430 Right. 93 00:05:21,430 --> 00:05:23,940 Well, let's put it like this and see what's happening. 94 00:05:24,340 --> 00:05:28,390 OK, now I've got only the values, which is super, super easy now. 95 00:05:28,570 --> 00:05:30,640 So I said Tom Cruise and actor. 96 00:05:30,790 --> 00:05:31,150 Right. 97 00:05:31,270 --> 00:05:34,640 Some great values for each object item. 98 00:05:35,530 --> 00:05:36,630 Now the entries. 99 00:05:37,570 --> 00:05:39,670 So this was the object and values. 100 00:05:39,700 --> 00:05:41,010 We have the object entries. 101 00:05:41,020 --> 00:05:44,470 I'm just going to copy it and I'm going to change these two entries. 102 00:05:46,190 --> 00:05:53,210 Right now, the entries will create a new era with the two parameters, the key and a value from the 103 00:05:53,210 --> 00:05:53,720 object. 104 00:05:54,020 --> 00:05:58,570 OK, and this is, by the way, the most powerful with the entries. 105 00:05:59,390 --> 00:06:05,120 This will produce three different areas with two length of two. 106 00:06:05,120 --> 00:06:05,430 Right. 107 00:06:06,410 --> 00:06:07,600 So the first time I have. 108 00:06:08,390 --> 00:06:16,520 So in a superposition, I have the first name of that object, the second position or actually the first 109 00:06:16,520 --> 00:06:17,810 position that will have the name. 110 00:06:18,020 --> 00:06:18,410 Right. 111 00:06:19,190 --> 00:06:22,970 So this is how the object entries working. 112 00:06:22,970 --> 00:06:27,650 So they will create and two elements, every with two elements inside. 113 00:06:28,350 --> 00:06:36,680 Now here we have more control than object and we can use the map the each because we now have the areas. 114 00:06:36,680 --> 00:06:39,980 We can use any function here that we want. 115 00:06:41,150 --> 00:06:48,380 OK, so to make this more easier, I will write a real case scenario here, for example, to I will 116 00:06:48,380 --> 00:06:58,040 select object users, for example, this object of the users will return us the least of the user names 117 00:06:58,250 --> 00:07:00,680 and their user name. 118 00:07:00,690 --> 00:07:01,010 Right. 119 00:07:01,220 --> 00:07:07,070 So actually these probably imagine that it's coming from some server and I'm going to say user name 120 00:07:07,070 --> 00:07:13,250 here, zero in column here again column. 121 00:07:13,250 --> 00:07:19,550 And I will say Rick here right now, the second one I will just copy a couple of times. 122 00:07:20,690 --> 00:07:22,450 One, two, three, four. 123 00:07:22,610 --> 00:07:26,480 So user name of one actually will be Tom. 124 00:07:27,770 --> 00:07:34,400 Username of to imagine this is coming from somewhere from the server and it will be a Jack. 125 00:07:34,670 --> 00:07:38,940 This will be Logan and this will be OK, Ian. 126 00:07:39,230 --> 00:07:42,800 OK, so here I will say three and four. 127 00:07:43,400 --> 00:07:46,880 OK, now we have four user names back. 128 00:07:47,210 --> 00:07:52,460 Right, so let's run this in when using the object that entries. 129 00:07:53,240 --> 00:07:55,170 That's why I didn't copy it. 130 00:07:55,190 --> 00:07:55,870 I've no idea. 131 00:07:56,450 --> 00:07:57,560 So object that entries. 132 00:07:57,560 --> 00:08:02,510 But remember to change the object here and let's keep it interesting. 133 00:08:03,720 --> 00:08:10,850 Pasted down hit enter here is I do have this user name Zero and Rick. 134 00:08:11,870 --> 00:08:22,280 But now the cool thing, what we can do is we can also get the new screen user name and the number in 135 00:08:22,280 --> 00:08:24,170 the name of the user name only. 136 00:08:24,170 --> 00:08:26,750 I need the number actually and the user name. 137 00:08:26,750 --> 00:08:27,080 Name. 138 00:08:27,230 --> 00:08:27,600 Right. 139 00:08:28,370 --> 00:08:31,160 So this little bit of tongue twister for me. 140 00:08:31,160 --> 00:08:32,930 So I just want this number here. 141 00:08:34,790 --> 00:08:38,990 Zero column and the name of one column, Tom. 142 00:08:39,020 --> 00:08:40,690 OK, so how I'm going to do this? 143 00:08:41,060 --> 00:08:47,090 Well, it's super simple because we can use on the strings something that we can't use straight on the 144 00:08:47,090 --> 00:08:47,570 object. 145 00:08:48,710 --> 00:08:49,190 So I'm here. 146 00:08:49,190 --> 00:08:50,120 I'm going to see a return. 147 00:08:50,690 --> 00:08:55,690 I'm going to return a value because this is a value of zero, right? 148 00:08:56,150 --> 00:08:57,080 This is a value. 149 00:08:57,220 --> 00:08:59,150 If I go back here, it's a value zero. 150 00:08:59,360 --> 00:09:03,230 And it's always going to be even for the secondary, it's going to be value zero. 151 00:09:03,530 --> 00:09:12,080 And I you write it inside, then replace I can use that string method and I will say replace the user 152 00:09:12,200 --> 00:09:12,830 name. 153 00:09:13,070 --> 00:09:15,440 So it will find the user name until here. 154 00:09:16,880 --> 00:09:19,460 And I want to replace this one with what. 155 00:09:19,910 --> 00:09:20,650 With nothing. 156 00:09:21,590 --> 00:09:26,780 And this will concatenate me the value of one. 157 00:09:27,440 --> 00:09:31,910 Now I will have a readable output that it's working for me. 158 00:09:32,270 --> 00:09:33,590 I'm just going to copy it here. 159 00:09:33,590 --> 00:09:38,750 I'm going to pay it back and I'm going to do it like this and. 160 00:09:41,620 --> 00:09:50,320 It's not working for some reason and it's not working, I delete it, it's not working because we didn't 161 00:09:50,770 --> 00:09:53,290 consulate lock so we can cancel this log. 162 00:09:59,070 --> 00:10:03,520 So it's harder for me to write it here, so I'm going to consult before I was just returning it. 163 00:10:03,840 --> 00:10:04,610 Now, here it is. 164 00:10:04,620 --> 00:10:10,550 I do have zero free time Jack logo in Ian at the end. 165 00:10:11,040 --> 00:10:14,280 So this is how we can use the object entries. 166 00:10:15,460 --> 00:10:21,280 So instead here of returning, you can Cosla and you can just make this more meaningful result. 167 00:10:21,900 --> 00:10:30,180 Now one more thing before I go here, I want to mention that what we can do is, oh, actually in year 168 00:10:30,180 --> 00:10:37,920 eight there is a something that is considered as a normal way of writing and this is called trailing 169 00:10:37,920 --> 00:10:40,620 commas in function parameter list and calls. 170 00:10:41,190 --> 00:10:42,210 What the hell is this? 171 00:10:42,210 --> 00:10:42,430 Right. 172 00:10:42,810 --> 00:10:48,750 Well, it's nothing special, but let's write a function called some. 173 00:10:48,900 --> 00:10:51,990 And inside this function, I will have a couple of parameters here. 174 00:10:52,140 --> 00:11:01,080 A, B, sorry, A, B, C, the and I won't put extra comma here and I will write the error function 175 00:11:01,410 --> 00:11:10,020 like we did before and I'm going to cancel log the E plus B and in order to work this one, we need 176 00:11:10,020 --> 00:11:18,130 to call it some one to three for an extra comma because here we do have extra comma. 177 00:11:18,150 --> 00:11:26,320 Now if I copy this, clear this result, paste it back, hit, enter and read a declaration of some. 178 00:11:26,470 --> 00:11:33,660 OK, first I need to refresh this one and it will work because I've used that book before, so I was 179 00:11:33,660 --> 00:11:35,820 trying to show you something that I've used before. 180 00:11:35,830 --> 00:11:36,070 Right. 181 00:11:36,300 --> 00:11:37,230 So can some. 182 00:11:38,310 --> 00:11:41,100 You now have four parameters here, but additional comma. 183 00:11:41,130 --> 00:11:41,670 Why is this? 184 00:11:42,000 --> 00:11:46,590 Well, this is what the they say trailing commas and function parameter lists and calls. 185 00:11:46,990 --> 00:11:48,030 So I need this. 186 00:11:48,180 --> 00:11:48,630 Wow. 187 00:11:49,710 --> 00:11:54,330 Imagine that this will be useful only if you have a long, long, long parameter list here, like a 188 00:11:54,330 --> 00:11:54,720 twenty. 189 00:11:55,110 --> 00:12:01,180 And before we just going to start writing like this in order to make to be more readable. 190 00:12:01,320 --> 00:12:03,960 So this is only synthetic shuga of our write. 191 00:12:04,110 --> 00:12:08,520 But this comma actually will not throw you an error at this stage. 192 00:12:08,520 --> 00:12:11,380 And that is the what I want to show you. 193 00:12:11,550 --> 00:12:16,980 So even if you put a comma here, if you have a long parameter list, then this will not throw you on 194 00:12:16,980 --> 00:12:18,140 any any error. 195 00:12:18,570 --> 00:12:19,840 That's pretty much it. 196 00:12:20,530 --> 00:12:22,110 So nothing special. 197 00:12:22,110 --> 00:12:25,470 The first one, this one is pretty much I've never used it. 198 00:12:25,620 --> 00:12:26,790 So you don't have to worry about it. 199 00:12:27,000 --> 00:12:29,560 But object the entries and object. 200 00:12:29,570 --> 00:12:33,120 The values are pretty much cool before we were using this. 201 00:12:33,480 --> 00:12:40,860 But now we can use more things because we can convert with entries the object to an array and for the 202 00:12:40,860 --> 00:12:41,370 arrays. 203 00:12:41,370 --> 00:12:45,120 We do have a lot of functions and the first one was spatting. 204 00:12:45,120 --> 00:12:50,810 Start embedding and that will add spaces before the end of the string. 205 00:12:50,820 --> 00:12:52,200 These are just for the strings. 206 00:12:52,620 --> 00:12:54,060 So the async await. 207 00:12:54,450 --> 00:13:01,020 Now, the async away will cover a little bit in the next lecture, but it's covered in depth in one 208 00:13:01,020 --> 00:13:03,050 of the previous lectures. 209 00:13:03,090 --> 00:13:10,440 So if you want go back, just watch that promises in Async Away, because that is the most important 210 00:13:10,590 --> 00:13:13,470 part of its eight features.