Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Let's dive right into it with let and const. These are two keywords you're going to see a lot in this
course, especially const. Let and const are different ways of creating variables.
You know var, var creates a variable in javascript.
Now the thing is some variables never really change,
They are so-called constants.
Technically though, they are.
They are all just variables because javascript only knows var. With ES6, a version of javascript, two different
keywords were introduced, let and const. Var still works but you're highly encouraged to use let and const
Let is
so to say the new var, you use it for variable values. Let and const are all to changing something behind the
scenes about the scope of variables.
But the most important takeaway here is use let if you want to create a variable that really is variable.
Use const if you plan on creating a constant value, so something which you only assign once and never
change.
And that is the case more often than you might think.
In this course you will never see var, you will only see let and const and mostly it's const. So it
shouldn't confuse you,
It's simply the same as var, just in a more modern way, and in the case of const, although clearly
showing, this is never going to receive a new value.
Now since this is always a bit clearer in practice let's have a look at it. For this,
It's best if you use jsbin
.com,
That's another web editor which makes it easy for us to enter some javascript and see some console output
for that, disable HTML and output up there and instead to enable Javascript and console.
Now on the left side you can right next generation javascript, on the right side you'll see the output.
So there we can create a variable.
My name, set an equal to Max, console log my name, now hit control enter you'll see Max on
the right,
Not that new to you probably.
Obviously we can then set my name to Manu and if we then console log my name again.
It might also not totally surprise you that if you clear and run this again you'll see Max
From the first statement and Manu from the second one.
Now if you change var to let,
Nothing's going to change.
Hitting run still works the exact same way. If you use const though like this.
Then clearing and running this will output Max,
But then throw an error, since we try to reassign a constant variable which is kind of a strange name.
This is const and this is the idea behind const.
You can say this should never get a new value and if you then accidentally write some code where you
reassign it you get the error and hence a chance to improve your code.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.