1 00:00:02,280 --> 00:00:08,880 Now that I had a quick look at the very basics and the core terms you have to know, let's dive into some 2 00:00:08,880 --> 00:00:15,780 next gen javascript syntax you'll see throughout this module or throughout this course. Var is a keyword that 3 00:00:15,780 --> 00:00:17,380 creates a new variable 4 00:00:17,380 --> 00:00:26,370 and actually it's a bit of an outdated syntax, from now on we'll use let instead of var and let also 5 00:00:26,370 --> 00:00:31,550 creates a variable, the scoping behaves a bit differently but we can ignore that for now 6 00:00:31,550 --> 00:00:38,130 here, check out some next-gen javascript resource like my ES6 course or of course also some free resources 7 00:00:38,130 --> 00:00:40,220 to learn all about let 8 00:00:40,320 --> 00:00:48,090 but the core reason for using let is that we now also have another way of creating a variable and with 9 00:00:48,090 --> 00:00:52,800 that, I mean a variable which never changes which actually is the case for all three here. 10 00:00:52,860 --> 00:00:59,310 But let's say we actually do assign a new value to age here but we never change name or has hobbies, 11 00:00:59,880 --> 00:01:01,470 we could absolutely use let, 12 00:01:01,470 --> 00:01:03,650 there is nothing strictly wrong with that 13 00:01:03,810 --> 00:01:10,070 but to be clear about our intentions in the code and we know that we'll never change 14 00:01:10,140 --> 00:01:13,310 let name and has hobbies, 15 00:01:13,500 --> 00:01:20,010 we can also use a new keyword available in javascript and that's the const keyword. This creates a 16 00:01:20,010 --> 00:01:21,660 so-called constant 17 00:01:21,780 --> 00:01:27,350 and this makes clear that we never plan on changing the value of name or has hobbies. 18 00:01:27,540 --> 00:01:29,590 We do plan to change it of age 19 00:01:29,590 --> 00:01:36,000 and that is why we have let and that is the reason why we have two different keywords for creating variables, 20 00:01:36,080 --> 00:01:36,340 though 21 00:01:36,360 --> 00:01:42,570 again these are not really variables, they are constants, either const or let depending on whether you 22 00:01:42,570 --> 00:01:44,940 plan to change this or not. 23 00:01:44,940 --> 00:01:52,980 So now if I execute this, it works in exactly the same way as before but by the way, if I would try to set name 24 00:01:52,980 --> 00:02:00,380 to Maximillian here and I do run node play.js again, I actually get an error 25 00:02:00,380 --> 00:02:06,780 now, that I try to assign to a constant variable. So this actually already shows us the idea behind const 26 00:02:07,080 --> 00:02:14,070 and you want to use const as often as possible to be as clear about what happens in your code as possible 27 00:02:14,370 --> 00:02:19,080 and if something should never change, make it a const so that you get an error 28 00:02:19,110 --> 00:02:22,930 if you do accidentally change it. So here I'll revert this change 29 00:02:23,010 --> 00:02:25,610 but I wanted to show you how let and const work.