1
00:00:00,360 --> 00:00:01,230
Hello again, everyone.

2
00:00:02,220 --> 00:00:09,330
So we're going to start a new lesson, and in this lesson, we'll talk about data types in TypeScript.

3
00:00:10,860 --> 00:00:17,070
So actually, I think you're probably familiar with this topic from earlier JavaScript and different

4
00:00:17,070 --> 00:00:22,920
programming languages that you may know already, but in this lesson I want to talk about the intricacies

5
00:00:22,950 --> 00:00:24,510
of typescript.

6
00:00:25,800 --> 00:00:30,870
So basically, when we say the data type of a variable, well, the first things that come to mind will

7
00:00:30,870 --> 00:00:33,180
be values such as string and number and boolean.

8
00:00:34,410 --> 00:00:38,100
So let's see how these values are defined in typescript and how they're used.

9
00:00:39,380 --> 00:00:43,730
So now we first use the let key word to define a variable.

10
00:00:45,170 --> 00:00:48,440
And the name we want to use after, for example, say X here.

11
00:00:49,310 --> 00:00:57,470
And we put in a call in and the type that we want to specify, so we'll use String as our first example.

12
00:01:00,100 --> 00:01:07,570
So then we can give the value just by putting equals or we can define it this way and give the value

13
00:01:07,570 --> 00:01:08,140
later.

14
00:01:09,360 --> 00:01:11,370
Another way to define it could be.

15
00:01:13,220 --> 00:01:14,540
Just like we do here.

16
00:01:16,810 --> 00:01:22,000
We first specified that we will use string data and then we set a value.

17
00:01:23,390 --> 00:01:27,770
It's now the final variable, why using Aulet key word again.

18
00:01:28,960 --> 00:01:36,190
And I give a number as the first value well, actually, by doing this, I indicate that I have defined

19
00:01:36,190 --> 00:01:37,180
a number of variable.

20
00:01:38,900 --> 00:01:47,570
And if I then go and assign a string value to the variable, why here is TypeScript warning me.

21
00:01:48,730 --> 00:01:56,590
It tells us that you have defined variable Y as a number, you cannot give a string value and as you

22
00:01:56,590 --> 00:02:00,460
know, we won't see that warning in JavaScript.

23
00:02:02,070 --> 00:02:06,540
All right, so that's that's why defining this is important here.

24
00:02:07,750 --> 00:02:11,830
So why don't we talk about which variables will use?

25
00:02:12,970 --> 00:02:16,120
All right, so we've already seen that we can use strings and numbers here.

26
00:02:17,120 --> 00:02:19,670
And we can assign a boolean value.

27
00:02:25,430 --> 00:02:28,340
And of course, billions will take a.

28
00:02:31,850 --> 00:02:33,560
Value of true or false?

29
00:02:38,460 --> 00:02:40,890
We can also define a race.

30
00:02:41,840 --> 00:02:48,800
So for this, we can make a few different definitions, we can see them if you want to, because you

31
00:02:48,800 --> 00:02:51,860
know that we can use square brackets in the array definition.

32
00:03:02,260 --> 00:03:06,930
Of course, we can prepare a string, not just as a number, but in a list.

33
00:03:11,630 --> 00:03:12,940
So I want to show you another use.

34
00:03:14,100 --> 00:03:15,480
Now, one type array.

35
00:03:16,820 --> 00:03:20,720
And to find the array type between the greater than in maths and science.

36
00:03:22,490 --> 00:03:28,580
Now, here again, assuming we have prepared a series of numbers, the right number here.

37
00:03:29,570 --> 00:03:36,350
So what if I use a string expression and an array that I define as no in this way?

38
00:03:37,710 --> 00:03:43,890
Of course, it's going to give us a warning here, because we stated that it's a no ray.

39
00:03:45,560 --> 00:03:51,170
But if we don't want to make any definitions here, there won't be any warning, as you can see here.

40
00:03:53,270 --> 00:03:53,630
Cool.

41
00:03:53,750 --> 00:03:58,940
So there's also a tuple type that allows us to define a different data type array.

42
00:03:58,940 --> 00:04:01,220
And TypeScript, you can see how.

43
00:04:01,370 --> 00:04:09,020
All right, so now, while doing the definition, we can specify that the first element in this array

44
00:04:09,020 --> 00:04:12,100
can be a number in the second element can be a string.

45
00:04:12,770 --> 00:04:18,440
And here I use number as the initial value, then a string value.

46
00:04:19,550 --> 00:04:24,920
So at this point, we should pay attention to the element with the index, zero is a number and the

47
00:04:24,920 --> 00:04:27,230
element with the index is a string.

48
00:04:29,390 --> 00:04:32,200
So if we move around here, then we get an error.

49
00:04:34,770 --> 00:04:37,020
So that's why you have to be careful at this point.

50
00:04:41,070 --> 00:04:42,960
All right, so we can refer to any.

51
00:04:44,050 --> 00:04:45,910
As another data type.

52
00:04:47,230 --> 00:04:51,840
So sometimes there may be uncertainty about which data type to use while developing a project.

53
00:04:53,050 --> 00:04:57,250
So at that point, any data type comes to our rescue.

54
00:04:58,630 --> 00:05:06,910
And here we just determined the variable using the let keyword while defining then we can define as

55
00:05:07,030 --> 00:05:16,240
any if we want to or if we don't specify anything here, then we can define different data types later.

56
00:05:23,290 --> 00:05:24,250
Just like we do here.

57
00:05:25,390 --> 00:05:29,650
And as you can see, we've defined this way and received no errors.

58
00:05:34,990 --> 00:05:38,140
But we also know that when we did type assignment.

59
00:05:39,400 --> 00:05:41,890
We could not give any values like this.

60
00:05:44,800 --> 00:05:48,490
So as the next variable type, we can refer to ENUM.

61
00:05:49,460 --> 00:05:56,300
So Inam is a data type that does not have JavaScript, but it comes with TypeScript.

62
00:05:57,500 --> 00:06:04,740
Allows us to number in more meaningful ways, so I'll show you a small example of colors here.

63
00:06:06,000 --> 00:06:11,400
So use this data type Inam and then I wrote Colors and.

64
00:06:13,990 --> 00:06:15,670
I'm typing in a few different colors.

65
00:06:22,440 --> 00:06:27,060
When we are going to use, like, the red color somewhere here.

66
00:06:31,460 --> 00:06:34,640
The value returns to us will be zero by default.

67
00:06:35,730 --> 00:06:40,710
It's now and we define the red variable and call it here, the next value zero.

68
00:06:45,530 --> 00:06:46,820
For the next couple hours, one.

69
00:06:50,820 --> 00:06:52,500
And then the next college to.

70
00:07:00,170 --> 00:07:04,690
As you can see, writing just like this makes it happen.

71
00:07:06,580 --> 00:07:09,640
So if I add another color in between.

72
00:07:12,020 --> 00:07:15,190
Of course, these numbers need to change.

73
00:07:17,920 --> 00:07:21,340
And if we don't want to encounter that kind of situation.

74
00:07:22,390 --> 00:07:24,400
You do the definition this way.

75
00:07:25,740 --> 00:07:27,900
So here we can define the number that we want.

76
00:07:28,470 --> 00:07:30,330
It doesn't have to even be in line.

77
00:07:31,600 --> 00:07:37,090
If I want to, I can set a value like five for this and three for that.

78
00:07:41,850 --> 00:07:47,450
Now, where I use them, I'll see five or three as a result.

79
00:07:49,820 --> 00:07:57,070
Now, if you want to, we can create our JavaScript file and see how this enumeration works.

80
00:07:58,470 --> 00:07:59,490
And as you remember.

81
00:08:00,600 --> 00:08:04,200
We were doing this just by running the TSA code in terminal.

82
00:08:07,140 --> 00:08:10,380
And yep, our jazz file has been created.

83
00:08:11,420 --> 00:08:19,370
And there you can see the infrastructure that we created in our tax file corresponds to the function

84
00:08:19,370 --> 00:08:20,510
and J.S..

85
00:08:24,430 --> 00:08:30,370
And when we look at our other codes, the let key word was replaced with VAR.

86
00:08:31,680 --> 00:08:38,250
So it's basically the same logic, just a few small changes, so I think that's enough for this lesson.

87
00:08:38,280 --> 00:08:40,230
What do you say now?

88
00:08:40,230 --> 00:08:45,710
There are a few more data types that I want to explain, but I don't want to go on too long here.

89
00:08:46,080 --> 00:08:47,960
We're going to talk about them in the next lesson.

90
00:08:48,750 --> 00:08:49,410
I'll see you then.

91
00:08:49,830 --> 00:08:50,790
Good bye for now.
