WEBVTT 00:06.190 --> 00:11.710 In the previous video you could see this block coping can become really confusing when used with function 00:11.710 --> 00:12.960 declarations. 00:13.000 --> 00:17.710 So what we're going gonna do here we're going to replace function declarations with function expressions 00:19.440 --> 00:25.110 like Vance. 00:25.710 --> 00:33.710 Now the problem is that if you use var it's going to ignore all the curly braces let's be using to create 00:33.710 --> 00:37.700 the blocks so far is definitely not the right choice. 00:37.740 --> 00:47.620 So instead of VAR Let's use let's and we know that let's works just fine with block scoping. 00:47.620 --> 00:57.260 So normally you would use something else called const which will come back to later but for now let's 00:57.260 --> 01:00.910 just use LEDs because that's the one that's we covered so fine. 01:00.940 --> 01:01.620 Yes. 01:01.910 --> 01:06.590 So let's replace all the function declarations using this function expression 01:17.020 --> 01:17.240 right. 01:17.240 --> 01:18.040 So let's save 01:21.510 --> 01:22.060 okay. 01:22.180 --> 01:27.250 So we're getting an error they're saying that Greece is not defined. 01:27.250 --> 01:35.020 That's because there is no hoisting when it comes to declaring variables using let's say let's just 01:35.950 --> 01:38.320 Comment this line for no. 01:38.630 --> 01:39.910 And now let's see what happens. 01:40.210 --> 01:42.370 So what we call Greece right there. 01:42.370 --> 01:50.350 We get high and that's what you would expect because you are setting Greece right there on the variable 01:50.380 --> 01:50.920 Greece. 01:50.980 --> 01:51.330 Right. 01:52.050 --> 01:56.810 And then inside this block group we've got. 01:56.820 --> 01:57.590 Hello. 01:57.600 --> 01:57.960 Right. 02:01.900 --> 02:03.720 That's expects it. 02:03.760 --> 02:11.870 And when you call Greeks they're it doesn't have access to this block. 02:12.000 --> 02:19.070 So he's gonna look in the same scope where it's called and it's being called in the global scope. 02:19.110 --> 02:24.520 So it's using about function expression. 02:24.530 --> 02:32.480 And finally when you call Greece again you don't have access to this block. 02:32.560 --> 02:42.400 All right using the function expression which is in the same scope which is the global scope. 02:42.460 --> 02:46.760 So now we're guessing high right there we're getting high. 02:46.810 --> 02:47.110 Right. 02:47.400 --> 02:51.210 The global scope and we are getting. 02:51.240 --> 02:51.640 Hello. 02:51.970 --> 02:59.000 So it's all makes sense now when using let say it's a lot easier to use. 02:59.010 --> 02:59.890 Let's. 03:00.160 --> 03:05.450 With a function expression instead of a function declaration when working with block scoping. 03:05.500 --> 03:11.410 Now again when the function doesn't change instead of using LEDs it's better to use concepts. 03:11.650 --> 03:14.320 But that's something that's going to cover later on in another video.