All language subtitles for 002 Understanding _let_ and _const__en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,210 --> 00:00:07,600 Let's dive right into it with let and const. These are two keywords you're going to see a lot in this 2 00:00:07,600 --> 00:00:13,970 course, especially const. Let and const are different ways of creating variables. 3 00:00:13,970 --> 00:00:17,920 You know var, var creates a variable in javascript. 4 00:00:17,930 --> 00:00:21,580 Now the thing is some variables never really change, 5 00:00:21,590 --> 00:00:23,750 They are so-called constants. 6 00:00:23,900 --> 00:00:25,360 Technically though, they are. 7 00:00:25,370 --> 00:00:33,020 They are all just variables because javascript only knows var. With ES6, a version of javascript, two different 8 00:00:33,020 --> 00:00:41,180 keywords were introduced, let and const. Var still works but you're highly encouraged to use let and const 9 00:00:41,870 --> 00:00:42,730 Let is 10 00:00:42,770 --> 00:00:50,030 so to say the new var, you use it for variable values. Let and const are all to changing something behind the 11 00:00:50,030 --> 00:00:52,750 scenes about the scope of variables. 12 00:00:52,850 --> 00:00:58,940 But the most important takeaway here is use let if you want to create a variable that really is variable. 13 00:00:58,940 --> 00:01:05,600 Use const if you plan on creating a constant value, so something which you only assign once and never 14 00:01:05,600 --> 00:01:06,400 change. 15 00:01:06,500 --> 00:01:09,710 And that is the case more often than you might think. 16 00:01:09,770 --> 00:01:16,490 In this course you will never see var, you will only see let and const and mostly it's const. So it 17 00:01:16,490 --> 00:01:17,780 shouldn't confuse you, 18 00:01:17,900 --> 00:01:24,590 It's simply the same as var, just in a more modern way, and in the case of const, although clearly 19 00:01:24,590 --> 00:01:28,570 showing, this is never going to receive a new value. 20 00:01:28,850 --> 00:01:34,340 Now since this is always a bit clearer in practice let's have a look at it. For this, 21 00:01:34,340 --> 00:01:35,950 It's best if you use jsbin 22 00:01:35,970 --> 00:01:36,730 .com, 23 00:01:36,740 --> 00:01:42,920 That's another web editor which makes it easy for us to enter some javascript and see some console output 24 00:01:43,490 --> 00:01:50,130 for that, disable HTML and output up there and instead to enable Javascript and console. 25 00:01:50,250 --> 00:01:55,780 Now on the left side you can right next generation javascript, on the right side you'll see the output. 26 00:01:55,820 --> 00:01:57,460 So there we can create a variable. 27 00:01:57,500 --> 00:02:08,639 My name, set an equal to Max, console log my name, now hit control enter you'll see Max on 28 00:02:08,639 --> 00:02:09,259 the right, 29 00:02:09,270 --> 00:02:12,300 Not that new to you probably. 30 00:02:12,300 --> 00:02:19,550 Obviously we can then set my name to Manu and if we then console log my name again. 31 00:02:19,710 --> 00:02:25,210 It might also not totally surprise you that if you clear and run this again you'll see Max 32 00:02:25,230 --> 00:02:29,220 From the first statement and Manu from the second one. 33 00:02:29,310 --> 00:02:31,310 Now if you change var to let, 34 00:02:31,310 --> 00:02:32,770 Nothing's going to change. 35 00:02:32,790 --> 00:02:39,750 Hitting run still works the exact same way. If you use const though like this. 36 00:02:39,780 --> 00:02:43,210 Then clearing and running this will output Max, 37 00:02:43,260 --> 00:02:50,480 But then throw an error, since we try to reassign a constant variable which is kind of a strange name. 38 00:02:50,720 --> 00:02:53,480 This is const and this is the idea behind const. 39 00:02:53,550 --> 00:02:59,100 You can say this should never get a new value and if you then accidentally write some code where you 40 00:02:59,100 --> 00:03:03,580 reassign it you get the error and hence a chance to improve your code. 4101

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.