All language subtitles for 006 Revisiting Variables & Values_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So with the import and export keywords

and the related concepts, we already explored a bunch

of crucial JavaScript concepts and features

which we'll use heavily throughout this course.

But of course, for this refresher

I now also want to take a step back

and also explore some other foundational JavaScript features

and concepts like working

with variables, values, functions, objects, and much more.

And it definitely makes sense to start

with variables, values, and operators, for that.

In this app js file, I'll comment

out all this code we wrote before

because we don't need it here, and instead

I now do want to revisit some foundational concepts related

to variables and values and operators.

Because in the end, when you're building an app

with JavaScript or with React, which uses JavaScript

of course it's in the end all about data and therefore

in the end values you are working with in your code.

If you take a look

at applications like Twitter or Google Maps, those apps

like all apps of course in the end are about data.

The tweets you write and read are data.

Your location is data.

The location you want to go to is data.

All these things are data that must be handled

in your code and in your Java script code.

You can therefore handle a broad variety of values.

Most importantly, strings, numbers, booleans.

This the special null and undefined values

which simply mean that a certain data container

a certain variable, doesn't contain any values yet.

And also the special object value to which I'll get back

later, now, a value in JavaScript can be created

in the place where you need it.

For example, if I want to output hello world here

I can simply create the string.

Hello world with double or single quotes, doesn't matter

but quotes are of course needed.

And if I then save this and reload my app

I would see hello world in the console.

So I can create values when I need them.

For example, here, when I need a value

as an input for this console

log command that's built into the browser in the end.

But it's also quite common that values should be stored.

And for that, you're using variables.

Variables are simply data containers where you store a value

in a variable which carries any name of your choice.

So you assign a name to a variable

and you can then use this variable name as an identifier

in your code to refer to that value that's stored

in this variable whenever you need to use that value.

And you typically use variables

because they allow you to reuse a value

and because they can help with code readability

because often it makes sense to not define the value

in the place where it's needed, but maybe instead ahead

of time so that your overall code stays a bit cleaner

and more readable.

Now, in JavaScript variables can be created

with the let keyword here.

I could create a variable named user message

though the name is up to you

it just should follow certain rules.

For example, it should be written using this camel

case notation where you start with a lowercase character.

And if your variable name then consists of multiple words

every word inside of the word

like message here starts with a capital case character

and it must not contain any dashes or white space.

So this variable name would be invalid just

as this name would be, underscores would be allowed

but are not common in JavaScript.

Instead, as mentioned

the convention is to use this notation.

Variable names also may contain numbers

but not at the beginning.

In addition

they also may not contain any special characters

like an exclamation mark or a question mark.

The only exception is the dollar sign and the underscore

which I already mentioned.

But other than that, the name is up to you.

And then I could store this hello world text

in user message.

If I then want to use this value, for example here

for logging it to the console, I would simply use the name

of the variable and thereby refer to this value.

And that's how I use a variable.

And if I now want to lock this multiple times, for example

I gain this reusability advantage by using a variable

because instead of having to copy and paste that value

I just define it once and then use that variable as often

as I want to use that value that has the advantage that

if that value ever needs to change, I only need to change it

in one place instead of multiple places.

And all the places in my code where I use that variable

will automatically use that changed value, with that.

If I reload this, I of course see hello world being output

in the console twice.

So that's how we create variables.

Now, related to variables, we also have constants

which are created with the const keyword.

If I save this and reload, I again see HelloWorld being

output twice here.

So constants work like variables, they are data containers.

But the key differences that constants must not be

reassigned, if I try to assign a new value,

a new string, for example, like this

I'm getting an error

that it's read only because it's a constant.

If I were using let here instead of const

everything would work instead.

Now I would again see my log here in the console.

So that's the key difference

with let, I can use this single equal sign operator to

assign a new value, with const, I can't.

Now, there are different philosophies out there.

In the JavaScript world

certain developers like to use const as often as possible

and I am one of those developers.

Other developers want to use let all the time

because it has less characters

and therefore requires less code to type.

But I prefer to be clear about my intentions

and if I have a value that never should be reassigned.

I personally prefer to use const.

You can use whatever you want

but you should know about the difference.

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