1 00:00:00,360 --> 00:00:06,490 Welcome back, ladies and gentlemen, today we are going to do S11 features in the reason why I haven't 2 00:00:06,490 --> 00:00:11,370 released what we are going to do in this lecture, because I don't know how long it will take, because 3 00:00:11,370 --> 00:00:15,480 there are a couple of features that I want to go through. 4 00:00:15,630 --> 00:00:19,800 So this is is 11 or ECMAScript, 20, 20. 5 00:00:20,070 --> 00:00:25,590 Now we are getting closer and as soon as they release the new features for twenty twenty one, I will 6 00:00:25,590 --> 00:00:27,150 just upload them as well. 7 00:00:27,180 --> 00:00:33,170 OK, now in this release, there's a one interesting feature called Big Integer. 8 00:00:33,180 --> 00:00:39,250 Now I'm just going to put it here as a number one, and it's called Big Int. 9 00:00:39,780 --> 00:00:41,880 So this is a very interesting feature. 10 00:00:42,030 --> 00:00:47,250 And in JavaScript there is a limitation of a no representation of what this means. 11 00:00:47,370 --> 00:00:50,520 There was a limit, max limit, how big the number can be. 12 00:00:50,820 --> 00:00:56,190 Now, this might be confusing because we never talk about this, but let's see, this can be represented 13 00:00:56,190 --> 00:00:57,600 with a number of primitive. 14 00:00:58,060 --> 00:01:07,210 So, OK, now, if I do console that log and if I say no like this, this is the number of primitive 15 00:01:07,230 --> 00:01:12,730 and say Max safe integer, they should give me this number. 16 00:01:13,020 --> 00:01:17,790 So this is the max safe integer that we can use. 17 00:01:18,060 --> 00:01:24,630 OK, so you can store it in a can in a concert if you want Max number like this. 18 00:01:25,790 --> 00:01:33,230 And put it there, right, called the max number, so this is the maximum number that we can use in 19 00:01:33,260 --> 00:01:33,890 JavaScript. 20 00:01:33,900 --> 00:01:39,290 So dear, how this number, it's coming, but where this number is coming. 21 00:01:39,300 --> 00:01:40,690 So this is two. 22 00:01:40,970 --> 00:01:45,340 So how you read this two to the power of 53. 23 00:01:45,560 --> 00:01:45,970 Right. 24 00:01:46,310 --> 00:01:54,320 And we can write it like this to power of two, comma. 25 00:01:54,320 --> 00:01:56,780 Fifty three minus one. 26 00:01:57,890 --> 00:02:01,860 OK, so if you do this in your calculator you will get the same number. 27 00:02:02,150 --> 00:02:06,990 OK, so that is how this max safe integer is calculated. 28 00:02:07,520 --> 00:02:10,800 So let's do something here. 29 00:02:10,810 --> 00:02:15,110 A little bit of experience const first number. 30 00:02:15,320 --> 00:02:21,470 Let's do it like this if I can type it right and let's say I'm going to say no. 31 00:02:24,210 --> 00:02:35,010 Bus one, OK, and Consed second number and I will use the same one, but I'm going to add two now I've 32 00:02:35,010 --> 00:02:37,900 told you that this or I can use Macs number plus one, right? 33 00:02:38,130 --> 00:02:43,520 Yeah, because we have a constant max number plus one and I can use Max number here as well. 34 00:02:44,460 --> 00:02:46,350 Plus two now basically. 35 00:02:47,690 --> 00:02:55,490 Because we reached the limit here with this one, and if I want to add one or two to this number, then 36 00:02:55,490 --> 00:02:56,870 then I will have problems. 37 00:02:57,380 --> 00:02:58,520 Look at what will happen. 38 00:02:58,710 --> 00:03:03,500 So if I comes along and I will say first, no. 39 00:03:04,410 --> 00:03:05,820 And let's do first number. 40 00:03:07,770 --> 00:03:08,310 There you go. 41 00:03:08,380 --> 00:03:09,500 It's a little bit different, right? 42 00:03:09,570 --> 00:03:14,150 It's one extra because we added one right to the first one. 43 00:03:14,430 --> 00:03:21,210 And let's put it here, Max integer limit. 44 00:03:21,930 --> 00:03:22,310 Right. 45 00:03:23,430 --> 00:03:28,480 And someone will say, well, the max integer limit, it's this and I get this. 46 00:03:28,500 --> 00:03:29,730 So what's the problem here? 47 00:03:29,760 --> 00:03:32,250 Well, look what I bring out the second one. 48 00:03:34,290 --> 00:03:37,030 Now, this should be 93 again, right? 49 00:03:37,470 --> 00:03:39,070 But look what will happen. 50 00:03:39,190 --> 00:03:41,490 No, it's not going to go there, right. 51 00:03:41,490 --> 00:03:42,700 Because there is a limit. 52 00:03:42,730 --> 00:03:47,940 So if we do some calculation with the numbers greater than safe integer, then we have a problem. 53 00:03:48,270 --> 00:03:51,930 And that is why big integer is coming. 54 00:03:52,320 --> 00:04:00,090 So big integer is actually inbuilt object that provides a way we can represent whole numbers larger 55 00:04:00,090 --> 00:04:02,700 than this power of two. 56 00:04:02,940 --> 00:04:03,240 Right. 57 00:04:03,780 --> 00:04:05,910 So two to fifty three. 58 00:04:06,840 --> 00:04:11,710 So that is why the they created this big integer. 59 00:04:11,940 --> 00:04:16,170 Let me just sit here and say make it so it's an object. 60 00:04:17,400 --> 00:04:22,770 And that provides a way how we can represent whole numbers larger than this element here. 61 00:04:23,160 --> 00:04:27,960 OK, so let's consider the big integer and say const. 62 00:04:29,400 --> 00:04:31,670 Let's create a variable called big. 63 00:04:33,710 --> 00:04:36,410 And put it like this here in Dejour. 64 00:04:38,160 --> 00:04:47,610 And this is actually this where is taken, you can just begin and it will be or integer, let's put 65 00:04:47,610 --> 00:04:53,250 it like this integer and that will be equal to big int. 66 00:04:55,700 --> 00:04:59,630 So no doubt, Max. 67 00:05:01,780 --> 00:05:03,430 Not actually, Max, safe, no. 68 00:05:05,370 --> 00:05:14,460 Max, safe integer, and let's council lock the big integer now and see what we have. 69 00:05:15,390 --> 00:05:23,490 Wow, you see that we have the same one on top, but we have it's a different color and we have and 70 00:05:23,490 --> 00:05:25,590 at the end, OK, just put it here. 71 00:05:25,600 --> 00:05:26,730 Big integer. 72 00:05:29,330 --> 00:05:30,060 Very good. 73 00:05:30,650 --> 00:05:31,130 So. 74 00:05:32,050 --> 00:05:34,690 Let's add another here. 75 00:05:36,500 --> 00:05:37,480 Console that law. 76 00:05:37,590 --> 00:05:44,840 I'm just going to do it like this, so I'm going to use these big integer and I'm going to add a one 77 00:05:44,840 --> 00:05:46,390 extra like I did it here. 78 00:05:46,640 --> 00:05:50,270 But in order to do that, I need to use again, big in. 79 00:05:51,410 --> 00:05:55,870 Like I did here, and I'm going to pass one here and I'm not going to save it. 80 00:05:58,270 --> 00:06:01,570 And this will be at 2:00 and here I will say. 81 00:06:03,110 --> 00:06:05,630 Plus one, right, just to know. 82 00:06:07,470 --> 00:06:17,010 Big in plus one, and this should be big and plus two, right? 83 00:06:19,560 --> 00:06:22,110 And comma here and now, save this, guys. 84 00:06:22,920 --> 00:06:27,510 Well, there you go now, plus one will give us two and plus two will give us three. 85 00:06:27,510 --> 00:06:28,470 And so. 86 00:06:29,980 --> 00:06:30,670 There you go. 87 00:06:30,700 --> 00:06:37,600 Now, if you observe, you can see that the Beacon Theater and its end to the end of an integer number, 88 00:06:37,630 --> 00:06:38,020 right? 89 00:06:38,810 --> 00:06:40,350 And that is pretty much it. 90 00:06:40,370 --> 00:06:46,370 What about the big integer now be integer is not same as no country. 91 00:06:46,380 --> 00:06:49,280 The team is number, so it is different. 92 00:06:49,550 --> 00:06:52,630 And we cannot use directly to a math object. 93 00:06:52,850 --> 00:06:56,890 We cannot be mixed with a number of instances and doing calculations with it. 94 00:06:56,900 --> 00:06:57,230 Right. 95 00:06:57,380 --> 00:07:00,340 So you can mix numbers with big integer. 96 00:07:00,560 --> 00:07:05,560 You need to do a typecast, but you're not going to worry about that thing at the moment. 97 00:07:05,900 --> 00:07:11,360 So I'm just going to tell you that because the numbers has its own limit, this is a primitive number. 98 00:07:11,370 --> 00:07:13,910 That's why we can access no massive integer. 99 00:07:14,210 --> 00:07:15,500 There's a limit. 100 00:07:15,830 --> 00:07:17,600 There is a this here. 101 00:07:17,600 --> 00:07:18,200 I'm just going to. 102 00:07:18,200 --> 00:07:18,850 Can I copy it? 103 00:07:19,790 --> 00:07:20,570 Yep, I can. 104 00:07:22,860 --> 00:07:28,830 So this is the max safe number, but now if you want to add one or two extra to that number, it's not 105 00:07:28,830 --> 00:07:29,300 going to work. 106 00:07:29,580 --> 00:07:32,610 So any calculations above this number will not be valid. 107 00:07:32,850 --> 00:07:35,000 That's why they introduced this big integer. 108 00:07:35,160 --> 00:07:39,870 But if you want to use it in connection with the numbers, you need to use typecasts. 109 00:07:39,870 --> 00:07:40,140 Right. 110 00:07:40,290 --> 00:07:43,200 So that's a little bit of work for us. 111 00:07:43,320 --> 00:07:45,090 And we are not concerned of that. 112 00:07:45,090 --> 00:07:51,510 But you need to understand there is a big integer and that's a new addition to the Atmos script 2020. 113 00:07:52,470 --> 00:07:57,630 Now, the next big thing in this is 11 is this operator. 114 00:07:57,640 --> 00:08:04,130 It's called mulish with double L coalescing. 115 00:08:05,460 --> 00:08:06,840 I can't even pronounce it. 116 00:08:08,520 --> 00:08:16,380 And operator, so newly leasing operator, and this is a logical operator and it's represented with 117 00:08:16,380 --> 00:08:17,760 this double question marks. 118 00:08:18,420 --> 00:08:22,620 Now it's a logical operator and deals with no or undefined values. 119 00:08:24,560 --> 00:08:33,860 With no, I'm just going to write it here or I'm going to do this and fine values so or mulish values, 120 00:08:33,860 --> 00:08:34,140 right. 121 00:08:34,430 --> 00:08:36,250 That's why it's called not knowledge. 122 00:08:36,620 --> 00:08:39,540 So it works a similar way as a logical operator. 123 00:08:39,560 --> 00:08:44,880 We did double pipe right here, the pipe one that was logical or operator. 124 00:08:45,380 --> 00:08:49,460 Now, it's not the same as logic, logical or operator. 125 00:08:49,640 --> 00:08:51,230 It's a contrast to that. 126 00:08:51,260 --> 00:08:51,570 Right. 127 00:08:51,590 --> 00:08:53,010 So that's why we're going to do it here. 128 00:08:53,010 --> 00:09:01,670 A couple of the couple of exercise, actually, just to make sure that you understand this point. 129 00:09:01,760 --> 00:09:02,120 Right. 130 00:09:02,600 --> 00:09:11,150 So a logical operator, it generally returns the left hand value if it's Truthy or it will return the 131 00:09:11,180 --> 00:09:13,910 rightside value if it falsey. 132 00:09:14,060 --> 00:09:14,510 OK. 133 00:09:15,340 --> 00:09:20,250 Let's see what our just said, wow, that was confusing, so I'm just going to say console that lock 134 00:09:21,640 --> 00:09:22,780 and I'm going to do it here. 135 00:09:23,200 --> 00:09:24,730 So zero. 136 00:09:25,780 --> 00:09:30,460 Or what's happening here, so zero or. 137 00:09:32,140 --> 00:09:38,500 Five, what you think it will get us, let's save it, it will return us five. 138 00:09:38,740 --> 00:09:44,410 So as I said this generally I'm just going to write it down because you're going to forget this one. 139 00:09:44,770 --> 00:09:53,440 So logical or operator returns the left. 140 00:09:55,960 --> 00:09:58,240 Hand value, if. 141 00:09:59,450 --> 00:09:59,990 True. 142 00:10:02,500 --> 00:10:03,090 Else. 143 00:10:06,240 --> 00:10:16,380 Returns the right now zero, it's considered as a false or a false value, and that's why it returns 144 00:10:16,410 --> 00:10:17,120 the right side. 145 00:10:17,370 --> 00:10:18,430 There is the definition. 146 00:10:18,450 --> 00:10:20,520 OK, so let's test this out. 147 00:10:20,850 --> 00:10:25,250 And to make this one look to look a little bit prettier, just based. 148 00:10:25,250 --> 00:10:26,430 This one here, a comma. 149 00:10:27,390 --> 00:10:28,110 And there you go. 150 00:10:28,650 --> 00:10:30,220 Now, also, you can do it. 151 00:10:30,240 --> 00:10:31,650 This comes to this. 152 00:10:31,980 --> 00:10:32,630 Nice. 153 00:10:33,330 --> 00:10:35,980 So let's do two more examples. 154 00:10:37,260 --> 00:10:45,550 Now, what if we have I'm going to put a double quotes here because I want to use an empty string here. 155 00:10:45,570 --> 00:10:52,310 So what if I have empty string here and let's say Rick here, but you think it will return, right? 156 00:10:52,500 --> 00:10:53,540 Let's do the same thing. 157 00:10:53,550 --> 00:10:54,330 Empty string. 158 00:10:55,500 --> 00:11:04,890 And Rick on the right side, so the logical operator returns the left end value, if it's true, else 159 00:11:04,890 --> 00:11:08,060 returns the right value, right. 160 00:11:09,060 --> 00:11:12,230 OK, so let's comment on the last one. 161 00:11:12,330 --> 00:11:13,740 Save it now. 162 00:11:13,740 --> 00:11:17,780 It returns, Rick, because we have what, falsey value. 163 00:11:17,790 --> 00:11:18,210 It's nothing. 164 00:11:18,220 --> 00:11:21,280 There is an empty string, and that's why I took this rightside. 165 00:11:21,360 --> 00:11:26,280 OK, let's confirm this thesis here. 166 00:11:26,400 --> 00:11:27,960 So cancel that lock in. 167 00:11:27,960 --> 00:11:31,560 I'm going to say here again, double quotes. 168 00:11:34,160 --> 00:11:36,230 Because if you want to use single quotes. 169 00:11:37,610 --> 00:11:39,180 You need to use double quotes outside. 170 00:11:39,200 --> 00:11:46,520 Now see here, Rick, and let's put it here, Andy, that both are what? 171 00:11:47,750 --> 00:11:48,770 True values, right? 172 00:11:49,010 --> 00:11:50,210 Let's put it here, Rick. 173 00:11:51,980 --> 00:11:57,520 Let's put it here, Andy, now what you think it will get us, it will get the first one, the left 174 00:11:57,520 --> 00:12:02,330 side always returns the left hand value if it's true right that. 175 00:12:02,350 --> 00:12:02,970 There you go. 176 00:12:02,980 --> 00:12:10,600 Now, the knowledge calfskin operator is running a little bit of different, so it returns the left 177 00:12:10,600 --> 00:12:11,360 hand value. 178 00:12:11,410 --> 00:12:15,070 So I'm just going to write this returns. 179 00:12:17,660 --> 00:12:18,740 Left hand. 180 00:12:20,910 --> 00:12:38,540 Value when the value is not no or undefined, what else returns, right value. 181 00:12:40,890 --> 00:12:41,490 Very good. 182 00:12:41,730 --> 00:12:43,460 Now, let's test this out. 183 00:12:44,160 --> 00:12:53,640 So I'm going to use the first line here, but instead of the operator here, I am going to use double 184 00:12:53,640 --> 00:12:59,130 question marks or knowledge call asking operator, write what you think it will return. 185 00:13:01,830 --> 00:13:03,780 It returns zero, right? 186 00:13:03,810 --> 00:13:09,360 It returns left hand side, then the value, it's not null or undefined. 187 00:13:09,360 --> 00:13:14,030 Cool, because this is not now zero is not null or undefined. 188 00:13:14,040 --> 00:13:16,030 That's why it returns a zero back to us. 189 00:13:16,350 --> 00:13:18,480 Now, let's do with empty strings here. 190 00:13:18,750 --> 00:13:19,130 Right. 191 00:13:20,760 --> 00:13:21,720 Let's try this one. 192 00:13:25,090 --> 00:13:33,100 And I need to close this one here, this one good, so I have empty string, then I get back the empty 193 00:13:33,100 --> 00:13:38,030 string, but you don't see it, but that's the empty string back, so it returns the left hand side. 194 00:13:38,590 --> 00:13:46,750 OK, let's check out the teases that it will return to rightside value if it's now or undefined. 195 00:13:46,870 --> 00:13:47,380 Hmm. 196 00:13:47,620 --> 00:13:48,720 Let's test this out. 197 00:13:48,910 --> 00:13:50,260 So let's put it here. 198 00:13:50,380 --> 00:13:51,280 If no. 199 00:13:52,590 --> 00:13:56,610 And five will return, what, five good. 200 00:13:59,340 --> 00:13:59,890 Nice. 201 00:14:01,890 --> 00:14:12,350 Let's do this one undefined and so if the thesis is right, it will return us again five. 202 00:14:12,630 --> 00:14:12,960 All right. 203 00:14:13,470 --> 00:14:18,590 Otherwise, it's always going to return to left operator here you can say operand. 204 00:14:19,170 --> 00:14:19,560 Nice. 205 00:14:20,010 --> 00:14:20,910 So there you go. 206 00:14:20,910 --> 00:14:25,810 The knowledge callsign operator is this one and yeah, that is pretty much it. 207 00:14:26,190 --> 00:14:26,700 So. 208 00:14:27,800 --> 00:14:35,630 You need to understand, so it is not possible to combine with other logical operators like and so you 209 00:14:35,630 --> 00:14:43,610 can't combine it together with and and or or this one so you can combine them. 210 00:14:43,650 --> 00:14:43,940 Right. 211 00:14:44,390 --> 00:14:50,320 But can be used when we include parentheses so we can use parentheses, so we can include both of them. 212 00:14:50,360 --> 00:14:50,690 Right. 213 00:14:50,930 --> 00:14:53,120 So let me just do one example here. 214 00:14:55,100 --> 00:14:55,850 Combination. 215 00:14:58,820 --> 00:15:07,550 Of awe and the knowledge, right, so let's say this console that long. 216 00:15:09,970 --> 00:15:11,140 Um. 217 00:15:12,620 --> 00:15:20,200 So we need to say here, double inside, we need another pair of brackets, so let's say Rick here, 218 00:15:21,260 --> 00:15:26,120 I wasn't planning this to include, but yeah, let's do it in falls. 219 00:15:28,010 --> 00:15:29,840 Now, outside, I will put the knowledge. 220 00:15:32,590 --> 00:15:34,450 And let's see here. 221 00:15:36,880 --> 00:15:37,780 My last name. 222 00:15:39,740 --> 00:15:41,840 So what, you think this will return back to us? 223 00:15:43,090 --> 00:15:44,620 It will return, Rick, right? 224 00:15:45,830 --> 00:15:53,120 Good, so it is working when we use a combination of all this knowledge and or operator, good, but 225 00:15:53,120 --> 00:15:55,460 you need to use the parentheses. 226 00:15:55,490 --> 00:15:57,230 It's not going to work without this parentheses. 227 00:15:57,460 --> 00:16:01,730 OK, let me just test this out and to show you that it's not going to work. 228 00:16:02,270 --> 00:16:07,630 See me saying, yeah, it's saying missing the after the argument list. 229 00:16:08,000 --> 00:16:08,400 Good. 230 00:16:09,650 --> 00:16:10,250 There you go. 231 00:16:11,650 --> 00:16:16,510 So the next thing that I want to explain here is called optional chaining. 232 00:16:19,850 --> 00:16:24,410 And it's looks like this dot and questionmark, OK, what is this? 233 00:16:24,680 --> 00:16:30,560 Before doing this, I would like to create an object, so let me just write it here. 234 00:16:30,560 --> 00:16:32,300 Optional genin. 235 00:16:32,990 --> 00:16:39,350 And this is not that very hard to understand, but it is a little bit tricky, OK, to grasp. 236 00:16:39,740 --> 00:16:44,580 So I'm going to create consed here person object in this person object will be nested right. 237 00:16:44,900 --> 00:16:51,950 So in order to check the nested object we need to run alse condition to see to avoid any undefined values. 238 00:16:52,010 --> 00:16:54,080 OK, let me just show it to you. 239 00:16:54,300 --> 00:16:55,640 So name here it will be. 240 00:16:55,910 --> 00:16:57,530 You can put any name here that you want. 241 00:16:57,800 --> 00:16:59,050 Now developer. 242 00:17:01,190 --> 00:17:01,610 True. 243 00:17:01,970 --> 00:17:04,220 Then we can say or says. 244 00:17:05,170 --> 00:17:11,570 So this is where the nest egg comes from, and I will say two courses, very good. 245 00:17:12,090 --> 00:17:14,580 Then again and let's see. 246 00:17:16,490 --> 00:17:27,450 Um, the the true nice, so there you go, we have a nested object and you should know all about objects, 247 00:17:27,450 --> 00:17:27,710 right? 248 00:17:28,120 --> 00:17:29,460 OK, so. 249 00:17:30,490 --> 00:17:37,650 Now, if I want to have this access here to get access to this truth, we usually do a safety check. 250 00:17:37,930 --> 00:17:53,800 So we will say if a person and person that course and we will see in person that cause. 251 00:17:55,050 --> 00:18:03,030 We should have courses here, right, courses that should be good courses, courses, it's more logical, 252 00:18:03,180 --> 00:18:03,510 right? 253 00:18:03,710 --> 00:18:07,080 And then I can see two courses. 254 00:18:07,470 --> 00:18:11,160 Then if this condition is true, let's say Konza like. 255 00:18:13,460 --> 00:18:21,920 It pass means that everything is working OK, is getting there so I can safely now console lock. 256 00:18:23,530 --> 00:18:26,260 The person that. 257 00:18:27,570 --> 00:18:32,760 Courses that two courses and web dev. 258 00:18:33,870 --> 00:18:40,140 There you should give me back to, right, if I have somebody here like two courses, it will give me 259 00:18:40,140 --> 00:18:41,380 back to courses, right? 260 00:18:42,660 --> 00:18:43,250 Let's do this. 261 00:18:43,260 --> 00:18:45,360 Two courses, nice or true? 262 00:18:45,480 --> 00:18:46,030 Doesn't matter. 263 00:18:46,500 --> 00:18:54,360 So this can be changed now with this changing operator, because actually what we did here is this is 264 00:18:54,360 --> 00:18:55,430 called a change, right? 265 00:18:55,590 --> 00:18:56,850 We change multiple conditions. 266 00:18:56,850 --> 00:19:00,300 We check if they are true, then we went here in this condition. 267 00:19:00,300 --> 00:19:05,100 And we just if everything is true, then this whole line will be executed. 268 00:19:05,100 --> 00:19:10,920 Right now, the optional training, this will be replaced here with something like this. 269 00:19:11,820 --> 00:19:15,990 So we can straight away we can see Conjola now, person. 270 00:19:16,650 --> 00:19:20,360 And I'm going to say questionmark that way. 271 00:19:20,490 --> 00:19:23,630 I think I'm not real a bit here. 272 00:19:23,670 --> 00:19:25,050 Should be questionmark. 273 00:19:25,050 --> 00:19:27,090 Not right, not questionmark. 274 00:19:27,100 --> 00:19:28,400 OK, I'm sorry about this guys. 275 00:19:28,830 --> 00:19:34,620 So yeah, I'm being it's been a long day for me so now I will say courses. 276 00:19:36,210 --> 00:19:39,570 But then again, questionmark not. 277 00:19:42,120 --> 00:19:50,850 So we can take courses, then we can say two courses, then questionmark not and in the end it will 278 00:19:50,850 --> 00:19:52,620 be weap dev, right. 279 00:19:53,640 --> 00:19:58,710 Let's comment on this part here and save this guy here. 280 00:19:59,070 --> 00:19:59,580 There you go. 281 00:19:59,580 --> 00:20:01,200 I have two courses as well. 282 00:20:01,500 --> 00:20:03,030 Let's change this back to true. 283 00:20:03,420 --> 00:20:04,530 To tell you that. 284 00:20:04,530 --> 00:20:06,090 To show you that it's working. 285 00:20:06,360 --> 00:20:07,380 There you go then. 286 00:20:07,380 --> 00:20:08,530 It is true. 287 00:20:09,210 --> 00:20:13,040 So this is pretty much more simpler than this, right. 288 00:20:13,230 --> 00:20:15,010 So this is the chaining operator. 289 00:20:15,330 --> 00:20:21,230 Now, if we made a mistake here, of course, for example, it will return us undefined. 290 00:20:21,240 --> 00:20:21,540 Right. 291 00:20:21,960 --> 00:20:22,360 Nice. 292 00:20:23,040 --> 00:20:26,330 So if you have this one so you know how to deal with those errors. 293 00:20:26,850 --> 00:20:27,490 There you go. 294 00:20:27,750 --> 00:20:28,920 Now you know another. 295 00:20:29,950 --> 00:20:31,570 Optional chaining operator. 296 00:20:32,760 --> 00:20:42,570 The next thing that I want to discuss is called number four, private class variable, and what this 297 00:20:42,930 --> 00:20:47,900 will do, it will restrict variables to be for internal use only. 298 00:20:47,940 --> 00:20:51,350 But I need to create a class for this in order to show you. 299 00:20:51,510 --> 00:20:54,120 So the number four will be private. 300 00:20:55,610 --> 00:20:57,930 Oops, class variable. 301 00:20:57,960 --> 00:21:04,830 OK, now let's create a class called person and how we would create a class. 302 00:21:04,830 --> 00:21:08,570 We use the key word with capital P, right. 303 00:21:08,880 --> 00:21:10,430 And class keyword as well. 304 00:21:10,560 --> 00:21:11,880 So class capital P. 305 00:21:12,270 --> 00:21:19,280 OK, now here I'm going to create a variable called my name. 306 00:21:19,380 --> 00:21:27,870 OK, and this my name will be right now if I want to do, if I want to create a private class variable, 307 00:21:28,110 --> 00:21:32,440 all I need to do is to get this hash symbol before it. 308 00:21:32,790 --> 00:21:37,620 Now if you use Firefox or any other browser, this might not work. 309 00:21:37,620 --> 00:21:38,760 It will throw you that. 310 00:21:38,760 --> 00:21:40,860 Our class are not supported yet. 311 00:21:41,190 --> 00:21:41,580 Right. 312 00:21:42,330 --> 00:21:46,160 But the Google does support this private class variable. 313 00:21:46,470 --> 00:21:50,160 So just adding hash before the variable makes it private. 314 00:21:50,460 --> 00:21:56,100 These assure us that this variable cannot be accessed directly from outside. 315 00:21:56,430 --> 00:22:04,590 OK, let's create some method here that you say get details and this method, that method will print 316 00:22:04,590 --> 00:22:07,470 the details so I don't put a constructor here. 317 00:22:07,680 --> 00:22:10,650 So this is just a very, very simple example. 318 00:22:10,650 --> 00:22:14,610 Please, just to make sure that you understand the private class variable. 319 00:22:14,850 --> 00:22:16,110 So return this that. 320 00:22:17,600 --> 00:22:25,260 Mining, right there you go and eat automatically at the hatch, right? 321 00:22:25,550 --> 00:22:29,810 So let's instantiate this class here and say const. 322 00:22:32,120 --> 00:22:37,020 PERSON one Well, let's call it Rick by my name. 323 00:22:37,880 --> 00:22:39,200 You can call your name. 324 00:22:39,380 --> 00:22:45,130 So how instantiated an object from a class with a new keyword and we add the person. 325 00:22:45,380 --> 00:22:49,340 Now we're going to pass the we're not going to pass anything to the constructor. 326 00:22:49,520 --> 00:22:49,940 Nice. 327 00:22:50,210 --> 00:22:52,280 So I can do calls along now. 328 00:22:53,450 --> 00:22:59,180 So, Rick, I want to access this, get details function. 329 00:23:00,740 --> 00:23:02,090 But because it's a function. 330 00:23:03,340 --> 00:23:07,830 And the OP, which would be, Rick, because it's a function we need troops to use this parenthesis. 331 00:23:07,840 --> 00:23:08,710 OK, save it. 332 00:23:09,280 --> 00:23:09,730 There you go. 333 00:23:09,730 --> 00:23:14,320 I do have access to Rick, but the private variable, that was not the intent. 334 00:23:14,560 --> 00:23:21,400 The intent was this variable cannot be accessed outside the class and this is outside the class directly. 335 00:23:21,520 --> 00:23:23,060 OK, so we can manipulate. 336 00:23:23,290 --> 00:23:26,810 So let me show this one to you, and we are done with this part. 337 00:23:27,070 --> 00:23:35,350 So, Rick, dot my name and they should throw us an error. 338 00:23:35,860 --> 00:23:36,600 Private field. 339 00:23:36,610 --> 00:23:40,930 My name must be declared in on enclosing class. 340 00:23:40,960 --> 00:23:41,490 Very good. 341 00:23:41,890 --> 00:23:44,000 So we can't actually access this one. 342 00:23:44,660 --> 00:23:47,930 Now this -- throws error. 343 00:23:48,880 --> 00:23:49,810 So there you go. 344 00:23:50,810 --> 00:23:55,640 We use private class where we will when we want to restrict a few variables, it can be a few variables 345 00:23:55,970 --> 00:24:02,000 for internal usage only so we can add only hash before the variable and that will make a private and 346 00:24:02,000 --> 00:24:03,120 can be accessed. 347 00:24:03,350 --> 00:24:09,800 It cannot be accessed outside this class, but it can be accessed and not manipulated, can be accessed 348 00:24:09,800 --> 00:24:11,330 by the methods here. 349 00:24:11,360 --> 00:24:12,870 OK, there you go. 350 00:24:13,280 --> 00:24:19,070 So these get details will bring out the output because this is not direct access. 351 00:24:19,070 --> 00:24:19,960 It's accessing. 352 00:24:19,970 --> 00:24:23,750 We are accessing the variable through the object. 353 00:24:23,960 --> 00:24:24,920 Through the method. 354 00:24:24,920 --> 00:24:25,280 Right. 355 00:24:25,580 --> 00:24:26,470 So save it here. 356 00:24:26,810 --> 00:24:27,060 Yeah. 357 00:24:27,120 --> 00:24:29,330 Everything goes back to normal. 358 00:24:29,450 --> 00:24:29,840 Nice. 359 00:24:31,370 --> 00:24:38,750 Now let's talk about another awesome feature in iOS 11, and that is called Promis. 360 00:24:42,850 --> 00:24:44,040 All settled. 361 00:24:47,290 --> 00:24:47,630 Right. 362 00:24:47,950 --> 00:24:54,490 So this is the new feature and it's very, very useful in order to explain you these few feature, I 363 00:24:54,490 --> 00:24:57,160 need to create at least two promises. 364 00:24:57,160 --> 00:24:57,520 Right. 365 00:24:58,060 --> 00:24:59,800 Let me just do this. 366 00:25:00,060 --> 00:25:04,860 I think it was number five, so promise that all settled. 367 00:25:06,640 --> 00:25:07,150 Very good. 368 00:25:07,360 --> 00:25:14,290 Now I'm going to create cost Promis one, and this will be new promise. 369 00:25:16,000 --> 00:25:22,270 Remember, each and every promise has access to response and reject or resolve and reject that response. 370 00:25:22,800 --> 00:25:31,570 And inside, I'm going to create a set time out and it will this set time out? 371 00:25:32,080 --> 00:25:36,400 It will say response and this will be success. 372 00:25:38,010 --> 00:25:45,860 Very good in the time out will be let's put 2000 milliseconds or that is two seconds, right? 373 00:25:46,050 --> 00:25:47,320 So this is the first promise. 374 00:25:47,730 --> 00:25:51,300 Now, let's create a second promise by copying this and pasting it here. 375 00:25:51,570 --> 00:25:53,220 Just change this to two. 376 00:25:53,520 --> 00:26:00,780 And instead of resolving let's reject this promise and say your field, OK? 377 00:26:00,990 --> 00:26:04,420 And let's do this after ten thousand milliseconds. 378 00:26:04,680 --> 00:26:06,500 This should be after 10 seconds. 379 00:26:06,560 --> 00:26:06,880 Nice. 380 00:26:07,530 --> 00:26:08,010 So. 381 00:26:08,980 --> 00:26:11,500 What is promised that all? 382 00:26:12,630 --> 00:26:19,770 Settled means so the problem that all settlement receives honorary it is uncute in promise, promise 383 00:26:19,770 --> 00:26:20,240 felt good. 384 00:26:21,540 --> 00:26:28,770 So this promise that also will receive honorary with the status object of every promises. 385 00:26:29,040 --> 00:26:32,130 So here we do have two promises in this. 386 00:26:32,160 --> 00:26:43,230 If I do promise that all settled in each side, it will receive an array of the two promises that I 387 00:26:43,230 --> 00:26:45,750 have with the comma separated with the comma. 388 00:26:46,290 --> 00:26:48,420 Now, oops, that should be too. 389 00:26:49,140 --> 00:26:52,500 And so we can use that then. 390 00:26:52,530 --> 00:26:55,880 Now why do you have these two here. 391 00:26:55,890 --> 00:26:57,300 I don't need these two. 392 00:26:58,580 --> 00:26:59,400 Brackets, right? 393 00:27:00,020 --> 00:27:06,770 So promise that all settled, it will receive an array of the two promises with the status object of 394 00:27:06,770 --> 00:27:08,440 every promise that we pass here. 395 00:27:08,600 --> 00:27:09,770 So we passed two promises. 396 00:27:09,770 --> 00:27:11,510 There will be two status objects. 397 00:27:11,630 --> 00:27:16,310 So what I can do, I can change this with then and I will say data. 398 00:27:16,310 --> 00:27:17,450 I can console lock. 399 00:27:18,710 --> 00:27:25,670 The data now, because I've said this, when I save it, I've said this to 10 seconds, it will wait 400 00:27:25,670 --> 00:27:30,170 a little bit longer until you see the result on the other side. 401 00:27:30,200 --> 00:27:32,120 OK, let's wait for 10 seconds. 402 00:27:32,130 --> 00:27:36,460 Maybe it was too long, but yeah, now the second promise is longer. 403 00:27:36,500 --> 00:27:37,520 That's why we are waiting. 404 00:27:37,820 --> 00:27:43,760 But it waits until all of the promises are settled and it gives us an array. 405 00:27:43,820 --> 00:27:45,320 See here on a rate. 406 00:27:45,680 --> 00:27:46,770 Let's see. 407 00:27:47,330 --> 00:27:53,510 So in this array we do have the status fulfilled with the value of success and a status. 408 00:27:53,810 --> 00:27:57,550 We reject it and reason it's failed. 409 00:27:57,830 --> 00:27:58,150 Right. 410 00:27:58,490 --> 00:28:04,640 So it will wait until all of the promise are settled and then it will give us an array with the final 411 00:28:04,640 --> 00:28:10,550 data that we condoling consolingly right in here when the problem is that all we can pass multiple promises 412 00:28:10,550 --> 00:28:17,650 here as an array, and this will have the status object of every promise that has passed. 413 00:28:17,780 --> 00:28:22,510 So here is actually just sending the status that is failed. 414 00:28:22,520 --> 00:28:30,800 And the reason in here we are sending the resolved or fulfilled with the value of success. 415 00:28:31,640 --> 00:28:39,290 Now, you know, I promise that all and this is one of the feature that is helping us when we are dealing 416 00:28:39,290 --> 00:28:40,760 with multiple promises. 417 00:28:40,760 --> 00:28:41,060 Right. 418 00:28:41,450 --> 00:28:51,110 In this promises we use promise that all because we want to use on the promises that are dependent on 419 00:28:51,110 --> 00:28:53,360 each other so that I haven't mentioned. 420 00:28:53,510 --> 00:28:55,960 But that was the thing that I should mention in the beginning. 421 00:28:55,970 --> 00:28:59,850 So these two promises should be dependent on each other. 422 00:29:00,200 --> 00:29:06,590 So here we can use promises that will settle and we can pass is an array with the status object of every 423 00:29:06,590 --> 00:29:07,700 promise that we are passing. 424 00:29:07,970 --> 00:29:10,310 And it will wait here of 10 seconds. 425 00:29:10,310 --> 00:29:11,990 We can do a little bit less. 426 00:29:13,650 --> 00:29:14,910 Let's make it for five seconds. 427 00:29:14,940 --> 00:29:23,700 Save it and it will wait five seconds until each and every promise is resolved or settled, then when 428 00:29:23,700 --> 00:29:28,410 it's done, it will give us the data back and it will give us an array with the final data. 429 00:29:28,740 --> 00:29:31,140 OK, so that is a promise that all. 430 00:29:32,200 --> 00:29:38,830 So let's do another one, and this is called Global Dis, so in JavaScript we generally use the window 431 00:29:38,830 --> 00:29:39,300 object. 432 00:29:39,310 --> 00:29:41,020 Remember we used a window object. 433 00:29:41,020 --> 00:29:42,030 So if I cause a lot. 434 00:29:46,490 --> 00:29:54,980 There I get the window, but now we have a global object and global disorder, so in JavaScript we generally 435 00:29:54,980 --> 00:29:55,820 use the window. 436 00:29:55,820 --> 00:30:01,530 But if we use no JS or other platform, the window will not work. 437 00:30:01,820 --> 00:30:05,180 They have some different convention for accessing the global stuff. 438 00:30:05,180 --> 00:30:07,030 And there it's called global. 439 00:30:07,460 --> 00:30:11,030 So let's write this one here and say global this. 440 00:30:13,190 --> 00:30:16,060 And you don't have to worry too much about this, right? 441 00:30:17,240 --> 00:30:18,730 Global this. 442 00:30:20,480 --> 00:30:21,050 Yeah. 443 00:30:21,110 --> 00:30:23,420 Let's go back here, write it down. 444 00:30:23,420 --> 00:30:24,260 Global this 445 00:30:27,500 --> 00:30:27,890 now. 446 00:30:28,610 --> 00:30:30,530 So this is nothing but. 447 00:30:32,090 --> 00:30:34,040 How we are calling the global object, right? 448 00:30:34,220 --> 00:30:40,660 So in JavaScript, we use window in Web workers, we use self so we will not work. 449 00:30:40,670 --> 00:30:42,690 There is no as we use the global. 450 00:30:43,340 --> 00:30:48,930 So with the global dis, accessing the global object will be the standard across all environments. 451 00:30:49,160 --> 00:30:50,260 So that's what they're pushing. 452 00:30:50,270 --> 00:30:53,480 So they want to have a standard across each and every environment. 453 00:30:53,480 --> 00:30:57,720 Doesn't matter if we're using Noguez or what workers or whatever we use. 454 00:30:58,010 --> 00:31:00,540 So now global, this will work. 455 00:31:00,890 --> 00:31:05,110 So it works both in window and non window context. 456 00:31:05,480 --> 00:31:12,140 So you can have access to this global object and we can have access to these global object the same 457 00:31:12,140 --> 00:31:15,200 way in our JavaScript ecosystem. 458 00:31:15,200 --> 00:31:15,430 Right. 459 00:31:15,590 --> 00:31:20,420 We don't have any issues now how we can test if this is working? 460 00:31:20,660 --> 00:31:25,070 Well, we need to check if this global object is there in one chat. 461 00:31:25,120 --> 00:31:30,020 One thing that we can do is we can say Konza log. 462 00:31:32,320 --> 00:31:38,710 To global, this should be equal to the window and this, ladies and gentlemen, should return us back. 463 00:31:38,710 --> 00:31:39,060 True. 464 00:31:39,340 --> 00:31:46,750 So now we are making sure that we can use global object and its exist now with the new features. 465 00:31:46,850 --> 00:31:50,740 Oh, after a couple of seconds, we have we have the promise back. 466 00:31:50,740 --> 00:31:51,790 That's why that change. 467 00:31:51,940 --> 00:31:52,290 Right. 468 00:31:52,840 --> 00:31:54,390 Even it will in note. 469 00:31:54,400 --> 00:31:55,670 So this will not work here. 470 00:31:55,900 --> 00:31:57,790 Now if you use in worker. 471 00:32:00,270 --> 00:32:05,720 We're just going to say global, this will be equal to self, right? 472 00:32:06,030 --> 00:32:09,980 And in note, this will be global. 473 00:32:10,530 --> 00:32:13,950 This will be equal to global. 474 00:32:15,270 --> 00:32:20,440 Right in here, it's equal to window because we are using our window object. 475 00:32:20,460 --> 00:32:22,590 So that is pretty much it about the. 476 00:32:24,860 --> 00:32:30,050 That is pretty much about the global debt, so if you want, you can try in all of these three environments, 477 00:32:30,050 --> 00:32:33,080 but if you don't, that's that's up to you. 478 00:32:33,440 --> 00:32:36,920 So you need to know that we have access to global this now. 479 00:32:36,920 --> 00:32:41,000 And it's getting true when we see equal to the window. 480 00:32:41,240 --> 00:32:49,610 And this is done because we want to have the same to use the same environment in every every environment 481 00:32:49,610 --> 00:32:49,790 there. 482 00:32:49,850 --> 00:32:50,160 Right. 483 00:32:50,710 --> 00:32:51,110 OK. 484 00:32:52,380 --> 00:32:57,750 And there you go, we have covered a lot of things here, we have covered six there, a couple of more 485 00:32:58,080 --> 00:32:59,910 and I hope this was interesting. 486 00:32:59,910 --> 00:33:03,960 Some of these are not logical for you guys will probably never use them. 487 00:33:04,170 --> 00:33:05,970 But, yeah, get used to this. 488 00:33:06,360 --> 00:33:07,440 Call this an operator. 489 00:33:07,670 --> 00:33:09,780 That one was good and optional. 490 00:33:09,780 --> 00:33:11,960 Chaining private class names. 491 00:33:12,000 --> 00:33:12,410 Yeah. 492 00:33:13,080 --> 00:33:13,860 This problem. 493 00:33:13,860 --> 00:33:14,760 Is that all settled. 494 00:33:14,910 --> 00:33:15,360 Yep. 495 00:33:15,720 --> 00:33:19,410 For checking if the data that comes from all of the promises. 496 00:33:19,410 --> 00:33:19,800 Right. 497 00:33:20,130 --> 00:33:23,400 And global this now you just know that there is a global dis. 498 00:33:24,900 --> 00:33:25,320 Yeah. 499 00:33:25,590 --> 00:33:26,270 Object there. 500 00:33:26,370 --> 00:33:29,670 So thank you very much and I will see you in the next one.