1
00:00:00,560 --> 00:00:04,840
In this video, I want to add in a couple little notes around syntax of interfaces.

2
00:00:05,420 --> 00:00:09,500
So once again, when we define an interface, we're going to list out all the different property names

3
00:00:09,500 --> 00:00:12,290
and types that we expect, something that is a vehicle to have.

4
00:00:12,890 --> 00:00:19,400
We are not only limited to expressing primitive values inside of here, we can instead express any different

5
00:00:19,400 --> 00:00:21,750
type we want to inside of an interface.

6
00:00:22,310 --> 00:00:27,260
So, for example, let's say instead of the year property being a number, we instead want this to be

7
00:00:27,260 --> 00:00:31,850
a more complex object, like an instance of a date to do so.

8
00:00:31,850 --> 00:00:38,270
I'm going to replace no with simply date like so now in order for old Civic to be considered to be a

9
00:00:38,270 --> 00:00:40,760
vehicle, you'll notice that we've got an area down here.

10
00:00:40,850 --> 00:00:42,500
We have to update its definition.

11
00:00:42,980 --> 00:00:47,860
So instead of your being a simple number, I'm going to instead assignment an instance of a date like

12
00:00:47,870 --> 00:00:51,240
so as soon as I do so, that area down here goes away.

13
00:00:51,950 --> 00:00:57,200
So once again, we are not limited to just basic values or primitive values inside of an interface definition.

14
00:00:57,350 --> 00:01:00,200
We can assign any type inside there that we want.

15
00:01:01,160 --> 00:01:06,860
That also includes functions, so let's say that we want to say that in order for old Civic to be considered

16
00:01:06,860 --> 00:01:10,670
to be a vehicle, we want it to also have a function called summary.

17
00:01:11,300 --> 00:01:16,360
So in other words, I want this object right here to have a property or a function called summary.

18
00:01:16,400 --> 00:01:21,380
And if we call it maybe it should return a string that summarizes some different facts about the vehicle.

19
00:01:22,210 --> 00:01:25,390
To express that, I'm going to add in another property on vehicle.

20
00:01:26,590 --> 00:01:27,850
Called summary like so.

21
00:01:28,960 --> 00:01:33,730
And then instead of immediately putting in a set or a comma or see a colon right there, I'll put in

22
00:01:33,730 --> 00:01:37,360
a set of parentheses and then a colon right after it.

23
00:01:37,660 --> 00:01:41,020
And I'm going to label what I would expect the summary function to return.

24
00:01:41,290 --> 00:01:45,430
So in this case, maybe it's going to return a string that summarizes some different facts about the

25
00:01:45,430 --> 00:01:45,790
car.

26
00:01:46,900 --> 00:01:52,330
So this right here says that anything that wants to be a vehicle has to have a function called summary

27
00:01:52,750 --> 00:01:53,830
that returns a string.

28
00:01:55,060 --> 00:01:58,630
If we then go back down to the bottom again, you'll notice we have an area down here as well.

29
00:01:59,170 --> 00:02:03,450
So now it says that we do not have a summer property inside of old Civic.

30
00:02:04,150 --> 00:02:10,300
So to fix this up, we would have to add in a summary function that satisfies this type right here.

31
00:02:10,539 --> 00:02:12,700
So it has to be a function with no arguments.

32
00:02:13,670 --> 00:02:17,660
That returns a string and so we can add it on like so.

33
00:02:18,920 --> 00:02:24,110
So now to return some information about this vehicle, we could return about like.

34
00:02:25,290 --> 00:02:26,040
Name.

35
00:02:27,470 --> 00:02:33,630
Is this name like so and again, notice the yes, 2015 tablets drink here, so I am using tactics.

36
00:02:34,620 --> 00:02:40,920
So now that my object has a summary function that returns a string, it once again qualifies as being

37
00:02:40,920 --> 00:02:41,550
a vehicle.

38
00:02:42,410 --> 00:02:47,990
So if I go back down to the bottom of the pile again, that air has now gone away and now inside of

39
00:02:47,990 --> 00:02:52,550
my print vehicle function, rather than trying to pull off all these different properties one by one,

40
00:02:52,550 --> 00:02:55,040
I can instead rely upon that summary function.

41
00:02:56,130 --> 00:02:58,410
So I can call something like console that log.

42
00:02:59,670 --> 00:03:02,670
Vehicle dot summary like so.

43
00:03:05,480 --> 00:03:07,190
All right, so again, just two notes here.

44
00:03:07,550 --> 00:03:11,270
First off, we can use any type inside of our interface definition we want.

45
00:03:11,420 --> 00:03:13,850
We are not limited just to primitive values.

46
00:03:14,270 --> 00:03:19,730
Second important note is that inside of our interface definition, we can express functions inside there

47
00:03:19,730 --> 00:03:20,150
as well.

48
00:03:21,690 --> 00:03:25,350
So let's take a quick pause right here in the next video, I want to share two more important notes

49
00:03:25,350 --> 00:03:27,750
with you around basic syntax of interfaces.

50
00:03:27,900 --> 00:03:29,720
A quick pause and I'll see you in just a minute.

