1
00:00:00,940 --> 00:00:02,050
Hello again, everyone.

2
00:00:02,320 --> 00:00:09,520
So in this lesson, we'll talk about the class structure, in fact, when we look at JavaScript after

3
00:00:09,520 --> 00:00:20,820
S5 and ESX, it offers as well quite a great object oriented logic, like in Java or C Sharp.

4
00:00:21,700 --> 00:00:25,210
So this structure's become even stronger with TypeScript.

5
00:00:26,540 --> 00:00:31,570
So I'll start briefly with what class is and then I'll show you how to use it.

6
00:00:32,830 --> 00:00:37,090
Class is actually a structure that we can call object.

7
00:00:38,320 --> 00:00:46,420
Class can be briefly summarized as follows, but I'll give you an example, so.

8
00:00:47,470 --> 00:00:49,360
If we're talking about a car.

9
00:00:50,500 --> 00:00:55,790
We can talk about features, right, such as a brand of color, your manufacturer, model of the car

10
00:00:55,790 --> 00:01:03,790
or whatever, but also with this car we can go from place to place and gain in functionality.

11
00:01:03,950 --> 00:01:10,270
So in other words, classes are structures that contain both features and functionality.

12
00:01:11,800 --> 00:01:18,100
In fact, one of the best features of the class structure will bring to us is the ability to make regular

13
00:01:18,100 --> 00:01:25,630
software and to make sustainable software as well, because when we use a class structure, when there's

14
00:01:25,630 --> 00:01:32,050
a feature that we want to change just by making changes in one place, we can effect this feature that

15
00:01:32,050 --> 00:01:33,700
we wherever we use it.

16
00:01:35,740 --> 00:01:42,370
So, yeah, we can start writing now, now to use this structure will use the class keyword and then

17
00:01:42,370 --> 00:01:47,000
write the name and class names, always start with a capital letter.

18
00:01:47,500 --> 00:01:48,840
Got to be careful about that.

19
00:01:50,480 --> 00:01:51,740
Now let's prepare.

20
00:01:53,180 --> 00:01:59,330
Yeah, so this example that I just mentioned, so the class name is and I define properties in curly

21
00:01:59,330 --> 00:01:59,900
brackets.

22
00:02:02,590 --> 00:02:04,540
Such as brand model color.

23
00:02:09,660 --> 00:02:11,010
Year of manufacture.

24
00:02:15,500 --> 00:02:21,380
So now we've written property so we can assign properties using constructor.

25
00:02:28,500 --> 00:02:34,320
So, all right, constructor's and write properties that it can take as parameters, and I'm saying

26
00:02:34,320 --> 00:02:35,190
this.

27
00:02:38,790 --> 00:02:40,320
I'm assigning these properties.

28
00:02:44,770 --> 00:02:45,200
All right, cool of.

29
00:02:45,480 --> 00:02:49,270
So we have now to find properties and constructor's in the class.

30
00:02:50,890 --> 00:02:56,680
Now, let's add a method here that prints the production here, the council car.

31
00:03:05,370 --> 00:03:08,910
So as you can see, we can use this feature in this method.

32
00:03:13,160 --> 00:03:19,340
So why are we now create a new object from this class, so we use the new keyword for this?

33
00:03:20,150 --> 00:03:24,280
So look, when I write the class name here, it already shows the values.

34
00:03:25,370 --> 00:03:30,110
So this object that we created has all the features and methods in this class.

35
00:03:35,630 --> 00:03:38,600
All right, so let's write the features in order here.

36
00:03:56,230 --> 00:04:03,940
And look, when I want to print this object to the console log and look what I want to print this object

37
00:04:03,940 --> 00:04:08,170
in the console log after the name of the object, I'm putting a dot.

38
00:04:09,930 --> 00:04:13,920
And now we can see all the properties and methods in the class.

39
00:04:25,960 --> 00:04:31,300
So I can access the features of this class whenever I want by creating a new object.

40
00:04:42,550 --> 00:04:50,530
And we can define a second object for a different car here and here, we'll use different parameters.

41
00:04:58,850 --> 00:05:05,330
And when we print this second object so long, it will print these properties so we create a single

42
00:05:05,330 --> 00:05:12,140
class and by creating many objects from this class, we can use the same properties with different values.

43
00:05:19,270 --> 00:05:28,450
So if we want to add or delete one more of the features here, one or more, I might say, all we need

44
00:05:28,450 --> 00:05:30,370
to do is make changes within the class.

45
00:05:31,900 --> 00:05:39,310
All right, so that makes quick work, it's also very easy, way more organized, because we don't have

46
00:05:39,310 --> 00:05:42,100
to make changes in every single object.

47
00:05:47,060 --> 00:05:54,710
All right, so that's the class logic, I hope you got a good idea of how to use it, so I want to see

48
00:05:54,710 --> 00:05:55,450
in the next lesson.

49
00:05:55,700 --> 00:05:56,450
Bye for now.
