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
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
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
Now let's dig deeper into typescript.
And for this, I'll add a new basics.ts file.
In which we'll dive into some core basics you need to know
about typescript.
And for that, I wanna start with the basic types
you can work with in typescript
which you will need all the time.
And that will be our primitives, which we know
from JavaScript, numbers, strings and booleans.
And then of course, we also have more complex types
like arrays or objects, for example.
And then we're there after
we'll also talk about function types,
parameters and much more.
So that's generally what I wanna talk about here.
And let's start with the primitives here.
The primitive values we have
in JavaScript are numbers, strings, booleans
and also a null and undefined and also symbols.
But we can ignore that.
And number, string and boolean as well as null and undefined
are the important ones therefore.
Now if we have a variable, let's say, let's say the age
of a user, and we wanna make it cleater,
that India we wanna have a number.
We can make that clarification with typescript
by adding a colon after the variable name
and then simply specifying the type
of value that should be stored in this variable.
And then we can finish this variable declaration here.
If I then later assign a value, assigning a number is okay
including floats, so numbers with a decimal place
but assigning a string would give me an error.
That's what we saw before
with that function and its parameters as well.
Now, of course, we can also assign a value here right away.
We don't have to have this declaration
without a value assignment.
Both is allowed.
Now we also can of course have a username
which should be a string.
And for that, we can assign a type like this.
String is the type we wanna use here.
And one important note here,
in typescript it's number and string written like this
with lower case starting characters.
It's not number like this.
We don't get an error if we use that
but this actually points at the number object in JavaScript.
We want the number primitive type
which starts with a lowercase N, the same for string.
We want the primitive type,
which starts with a lowercase S
and then of course, here we can assign a value.
And we can also of course
store boolean values like is instructor
and add boolean as a type assignment so that their after,
I may store true or false in that variable.
And these are our core primitive value types
which we can assign, in this case to variables
before we also saw how we set types for function parameters.
And we'll see more places where we can set types
in the next minutes.
Now, as I mentioned, we also have null and undefined
as types, but we don't typically set something to be null.
If I set hobbies to null here, then this would be possible.
But then whenever I try to assign anything, I get an error
which of course is not too useful.
Instead we'll use null
and undefined in a slightly different way
which we'll learn about in a couple of minutes.
So number, strings and booleans,
are the core primitive value types we should be aware of.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.