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
So you have learned
how to declare and initialize a variable. Now you might be wondering
what are the kind of values that we can assign
to a variable? Well you seen strings, but we have more types.
Basically, in JavaScript we have two categories of types.
On one side, we have primitives, also called
value types. And the other types we have reference types.
In this lecture, we're going to focus on primitives, and you're going to learn about
reference types later in the course. Now in the category of
primitives, we have strings, numbers,
booleans, undefined, and null. Let's look at
each of these in action. So here we have a variable called
name which is set to a string, what we have here is
called a string literal.
That's just a fancy name for a string. Now let's declare a variable
and set it to a number. So let Age and set that to 30
and by the way I'm not 30 years old, but don't tell anyone, okay?
So this is what we call a number literal.
Now let's declare a boolean. A boolean can either be true
or false. So, let isApproved
to be true. This is what we call a
boolean Literal. And we use this in situations where we want to have
some logic. For example, if the order is approved,
then, it needs to be shipped. So the value of a boolean
variable can be true or false.
And by the way note that both true and false are reserved keywords,
so they cannot be variable names. Okay?
Now you have seen undefined before, so I can declare another
variable, firstName, if we don't initialize it, by default
it's value is undefined, but we can also explicitly
set this to undefined. But that's not very common,
in contrast, we have another keyword that is null.
So let me declare another variable, let's set this
to null. We use null in situations where we want
to explicitly clear the value of a variable.
For example, we may want to present the user with a list of colors.
If the user has no selection, you want to set
the selectedColor variable to null.
In the future, if user selects a color, then we are going to
reassign this variable to a color like red.
And then if they click red again, perhaps we want to remove the selection,
so we set this back to null. So we use
null in situations where we want to clear the value of a variable.
So these are the examples of primitives and value
types. We have strings, numbers, booleans,
undefined and null. Now in ES6 we have
another primitive that is symbol, and you're going to learn that later in the course.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.