1
00:00:00,950 --> 00:00:01,910
Hello again, everyone.

2
00:00:02,180 --> 00:00:07,270
So in this lesson, we're going to talk about interface, so let's get to it.

3
00:00:08,780 --> 00:00:18,290
So normally, as you know, interface does not exist in JavaScript, so creating a type safe structure

4
00:00:18,290 --> 00:00:19,770
is inherently difficult.

5
00:00:20,870 --> 00:00:28,460
We can say that the interfaces and typescript are basically developed to eliminate this difficulty and

6
00:00:28,460 --> 00:00:30,500
we really wouldn't be too far wrong.

7
00:00:32,000 --> 00:00:38,850
We could also say that the interface in typescript is basically a type definition.

8
00:00:39,890 --> 00:00:47,030
So while classes and functions describe the behavior of objects we can think of, interfaces is defining

9
00:00:47,420 --> 00:00:48,860
object types.

10
00:00:50,490 --> 00:00:56,160
Now, if you've worked with languages such as Java and C Sharp before, you're already familiar with

11
00:00:56,160 --> 00:00:56,820
this topic.

12
00:00:58,920 --> 00:01:05,910
But here we've already mentioned that we can collect similar features in one class and then can extend

13
00:01:05,910 --> 00:01:08,310
them to other classes when necessary.

14
00:01:09,570 --> 00:01:12,660
Actually, the interface works similarly.

15
00:01:14,570 --> 00:01:21,020
We can say that there are some differences, and if you want to make it clearer with a simple example,

16
00:01:21,920 --> 00:01:28,730
yes, let's we use the interface keyword to make a definition and then write the name.

17
00:01:34,440 --> 00:01:39,300
So also defined variables as strings, username, password and email.

18
00:01:52,420 --> 00:01:57,520
Now, here I'm writing a simple method that is using this interface and writing console.

19
00:02:05,630 --> 00:02:08,420
And the person has been registered.

20
00:02:21,610 --> 00:02:23,740
So when I call this method, look here.

21
00:02:29,360 --> 00:02:31,010
We see the parameters at once.

22
00:02:48,260 --> 00:02:51,560
So I need to send all parameters in this interface.

23
00:02:53,030 --> 00:02:59,480
And so we've added all parameters, and as you can see, when I add all the parameters, the error display

24
00:02:59,480 --> 00:02:59,960
is gone.

25
00:03:02,090 --> 00:03:08,210
So now I'm changing this variable to optional, so that means I'll put a question mark in here.

26
00:03:12,810 --> 00:03:15,840
So when I delete this parameter, there's no problem.

27
00:03:19,870 --> 00:03:22,660
So now, look, when I change this string value to a number.

28
00:03:27,480 --> 00:03:35,250
We got an error again, because the program warns me that there's no variable of type, no year, we

29
00:03:35,250 --> 00:03:39,330
already know that, but I wanted you to see it again.

30
00:03:42,100 --> 00:03:44,770
So now let's define a class.

31
00:03:49,210 --> 00:03:55,690
So I want to make the difference a little more clear and you'll see why, so I'll prepare a class and

32
00:03:55,690 --> 00:04:01,180
define variables and then after making these definitions, I'll create an object.

33
00:04:08,740 --> 00:04:15,670
And look at this, so I'm only using the name variable for this object, and I'm not going to give any

34
00:04:15,670 --> 00:04:17,280
value to the other variables.

35
00:04:18,460 --> 00:04:22,420
So now I'm writing a method for the class, just like in here.

36
00:04:28,540 --> 00:04:31,930
And when I call this method, I don't get any errors.

37
00:04:32,890 --> 00:04:33,580
Why is that?

38
00:04:33,610 --> 00:04:41,470
Well, I've only to find one variable here, but it's OK for class because while interfaces want to

39
00:04:41,470 --> 00:04:47,730
use all the variables define that is just not the case for classes.

40
00:04:49,150 --> 00:04:50,460
So you see where we're going with it.

41
00:04:51,820 --> 00:04:56,370
If we are to define all variables, we got to use interface.

42
00:04:56,800 --> 00:05:03,910
But if you're not in that situation, we can say that we can use and define class.

43
00:05:07,960 --> 00:05:14,980
So you remember earlier when we were extending the class, well, likewise, we can implement interfaces.

44
00:05:18,080 --> 00:05:19,400
Just use the same logic.

45
00:05:24,690 --> 00:05:29,160
All right, my friends, so we're going to talk about generics in our next lesson.

46
00:05:29,760 --> 00:05:30,640
Hope to see you there.

47
00:05:31,410 --> 00:05:31,880
All right.
