All language subtitles for 1- Variables

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
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
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

Let's start this section by a discussion

of variables, which are one of the most fundamental concepts in JavaScript

and any other programming languages. In programming,

use a variable to store data temporarily in the computers

memory. So we store our data somewhere, and give that memory

location a name. And with this name, we can read the data at the

given location in the future. Here's a metaphor. Think

of the boxes you use to organize your stuff. You put your stuff in various

boxes, and put a label on each box. With this, you can

easily find your stuff. A variable is like a box.

What we put inside the box, is the value that we assign to

a variable, that's the data, and the label that we put on the box

is the name of our variable. Now let's see this in code.

So here in index.js, I'm going to declare a variable. Now,

previously in the old days, before ES6, we used the

var keyword to declare a variable. But there are issues with

var as you will find out later in the course. So, going forward

from ES6, the best practice is to use the

let keyword to declare a variable. Now, we need to give this variable

a name, or an identifier, and this is like the label we put

on a box. So I'm going to call this name, and finally we need to

terminate this declaration with a semi colon. Now let's log this

on the console and see what we get. So console.log

name, once again we need to terminate this statement

with a semi colon. Save the changes, and here in the console

we see undefined. So by default variables

that we defined in JavaScript, their value is undefined. Now we can optionally

initialize this variable. So I'm going to set this

to be a string, which is a sequence of characters,

like Mosh. Note that I'm using single quotes,

we can also use double quotes, different developers have different

purposes, but it's more common to use single quotes for declaring strings,

in JavaScript. Now when you save the changes,

instead of undefined, we see Mosh on the console. So,

here in this example we have declared a variable called name, and we have set that to

this value, to this string. Now, we have a few rules

for naming these variables. Here are the rules,

first is that they cannot be a reserved

keyword. So in JavaScript we have reserved keywords,

let is one of them. We also have if, l's

var and so on. Now you don't have to memorize this list, if you try

to use one of these names, you're going to get an error. For example, if I change this

to if note this red underline.

This is indicating that this is not a valid identifier, okay?

So, we wrote it back, now, the second rule

is that they should be meaningful. We want to have meaningful

names, like meaningful labels. I've seen developers using

names like a or b or a1 or

I don't know, x. These variable names don't give us any clue what is

the purpose of these variables. What kind of data are we

storing in that memory location? So always use meaningful and descriptive

names. Okay? Now, back to name

the third rule is that they

cannot start on a number. So we cannot have a variable like 1

name. But again, going back to the same rule, why would you want to call

a variable 1name? It's meaningless, right?

So, always use meaningful names. The fourth rule

is that they cannot contain a space or hyphen.

So if you have multiple

words we need to put them together. Here is an example, let's imagine we want to declare a

variable called first name. So firstName

and note that here I'm using camel notation, so the first

letter of the first word should be lowercase, and

the first letter of every word after should be upper case. This

is what we call camel notation, which is the convention we use in

JavaScript to name our variables. Another thing you need to know about

these variable names, is that they are

case-sensitive, so if I declare another variable,

call it first name, but make the f upper case,

these two variables are different. But as I told you

before, if you stick to camel (?) notation, you will end up with a variable

name like this. And finally the last thing you need to know about these

variables, is that if you want to declare multiple variables, there are

two ways to do this. You can declare them on one line

and separate them using a comma, so first name, then last

name. Now in this case, I have not initialized either of these

variables, they're both undefined, I can optionally initialize

1 or both of them, so I can set this to Mosh, and I can

leave lastName undefined or set it to my last name, Hamedani,

but the modern best practice is to declare each variable

on a single line. So we terminate

this first declaration with a semi-colon, and I declare the second variable on a new line.

That's the modern best practice.

Next we're going to look at constants.

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