WEBVTT 00:06.820 --> 00:13.600 In this video you're gonna get introduced to the letters declaration in Essex so the less declaration 00:13.600 --> 00:20.950 is very similar to the violent declaration but instead of using the vile keyword you use the less keyword 00:21.070 --> 00:22.900 like this. 00:22.900 --> 00:29.890 Now there are many common points between the less declaration and divine declaration but they do differ 00:30.310 --> 00:31.600 in many aspects. 00:31.600 --> 00:39.640 So for example if you read declare X you will get an error and this wouldn't happen with the declaration. 00:42.210 --> 00:49.750 So you cannot re declare a let terrible so read declaration. 00:52.840 --> 00:56.850 Throws an error unlike Von. 00:58.250 --> 01:00.950 So that's one of the key differences. 01:00.960 --> 01:02.890 Now let's move to scope. 01:03.000 --> 01:18.420 So if he if you declare a variable X and say 2 1 then creates a function and which returns y plus X 01:19.200 --> 01:26.150 then you try and 0 3 then you know you're gonna get 4. 01:27.080 --> 01:32.610 And that's because when you get to that line you're going to look for the value of x inside the execution 01:32.610 --> 01:34.800 context of all and you don't find it. 01:34.890 --> 01:39.150 Then you move to the US environment and you find this right there. 01:39.570 --> 01:42.380 So lets variables 01:45.760 --> 01:57.050 can be accessed from inside functions if declared in their outer environments. 01:57.080 --> 01:59.330 Just like what. 01:59.660 --> 01:59.930 No. 01:59.950 --> 02:10.450 Let's create another function of 2 which takes y and returns y plus x. 02:10.450 --> 02:22.000 But this time we're going to declare X inside the function and set it to 2 so if you try and two of 02:22.300 --> 02:25.210 three then you get five. 02:25.270 --> 02:30.130 And that's because when you get to that line we're going to look for X inside the execution context 02:30.190 --> 02:33.290 of 0 2 and you find it right there. 02:33.400 --> 02:46.080 So this is very similar to what would happen if we declared X using var so to know this is very similar 02:46.320 --> 02:46.860 to the. 02:46.890 --> 02:52.890 Var declaration apart from the reader coloration which throws an error. 02:52.910 --> 02:55.910 Now let's look us hoisting. 02:56.140 --> 03:07.880 Now we know that variables declared using var they are hoisted just like functions declared using the 03:08.060 --> 03:10.340 function declaration like that's 03:13.730 --> 03:26.850 now if you log a variable Z before declaring it then you will get an error. 03:26.850 --> 03:28.900 And the reason why is because 03:31.330 --> 03:42.240 variables declared using LEDs in E6 they are noise not hoisted unlike variables declared using one. 03:42.330 --> 03:50.830 Now if you had var Z you wouldn't get an error but you would get s undefined because we know that this 03:50.830 --> 03:57.550 variable is gonna be hoisted and set to undefined before the execution of your code so when you get 03:57.550 --> 04:02.460 there you know that z is already set to undefined and you get undefined. 04:02.560 --> 04:08.880 Now if you use let things are different and you get an error. 04:09.130 --> 04:20.400 Now there is a popular term amongst programmers which refers to the period between entering scope and 04:20.640 --> 04:24.260 being declared so. 04:24.300 --> 04:31.100 This period is called the temporal dead. 04:31.140 --> 04:31.350 So 04:34.980 --> 04:44.690 now if you declare Z like once and then you log it without initializing it then you get undefined 04:48.100 --> 04:52.840 but remember it's not voice it so you can't do this before the declaration. 04:52.870 --> 05:00.340 Now if you set Z to 1 for example and your guess again then you get the correct. 05:00.360 --> 05:10.230 While this time so this was a quick introduction to the late declaration in Essex in the next few videos 05:10.680 --> 05:17.940 you're going to learn more about the declaration including block scoping and so on.