1 00:00:00,650 --> 00:00:05,480 In this video I want to add in a couple little notes around syntax of interfaces. 2 00:00:05,480 --> 00:00:09,740 So once again when we define an interface we're going to list out all the different property names and 3 00:00:09,740 --> 00:00:12,750 types that we expect something that is a vehicle to have. 4 00:00:12,940 --> 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:19,820 type. 6 00:00:19,820 --> 00:00:22,350 We want to inside of an interface. 7 00:00:22,370 --> 00:00:27,620 So for example let's say instead of the year property being a number we instead want this to be a more 8 00:00:27,620 --> 00:00:35,750 complex object like an instance of a date to do so I'm gonna replace no with simply date like so now 9 00:00:35,750 --> 00:00:40,940 in order for old Civic to be considered to be a vehicle in those so we've got an error down here. 10 00:00:40,940 --> 00:00:42,800 We have to update its definition. 11 00:00:43,040 --> 00:00:49,220 So instead of your being a simple No I'm going to instead assign it an instance of a date like so as 12 00:00:49,220 --> 00:00:51,920 soon as I do so that error down here goes away. 13 00:00:52,010 --> 00:00:57,170 So once again we are not limited to just basic values or primitive values inside of an interface definition 14 00:00:57,410 --> 00:01:03,620 we can assign any type inside there that we want that also includes functions. 15 00:01:03,670 --> 00:01:08,300 So let's say that we want to say that in order for old Civic to be considered to be a vehicle we want 16 00:01:08,300 --> 00:01:11,280 it to also have a function called summary. 17 00:01:11,350 --> 00:01:16,400 So in other words I want this object right here to have a property or a function called summary. 18 00:01:16,480 --> 00:01:21,340 And if we call it maybe it should return a String that summarizes some different facts about the vehicle 19 00:01:22,240 --> 00:01:29,660 to express that I'm going to add in another property on vehicle called summary like so and then instead 20 00:01:29,660 --> 00:01:35,060 of immediately putting in a set or a comma or C a colon right there I'll put in a set of parentheses 21 00:01:35,810 --> 00:01:41,330 and then a colon right after it and I'm going to label what I would expect the summary function to return. 22 00:01:41,330 --> 00:01:45,770 So in this case maybe it's going to return a String that summarizes some different facts about the car 23 00:01:46,840 --> 00:01:52,320 so this right here says that anything that wants to be a vehicle has to have a function called summary 24 00:01:52,830 --> 00:01:57,910 that returns a string if we then go back down to the bottom again you'll notice we have an error down 25 00:01:57,910 --> 00:01:59,200 here as well. 26 00:01:59,200 --> 00:02:04,210 So now it says that we do not have a summary property inside of old civic. 27 00:02:04,210 --> 00:02:10,570 So to fix this up we would have to add in a summary function that satisfies this type right here. 28 00:02:10,600 --> 00:02:15,740 So it has to be a function with no arguments that returns a string. 29 00:02:15,850 --> 00:02:18,940 And so we can add it on like so. 30 00:02:19,000 --> 00:02:29,110 So now to return some information about this vehicle we could return about like name is this name like 31 00:02:29,110 --> 00:02:34,580 so and again notice the yes 2015 template string here so I am using back tax. 32 00:02:34,660 --> 00:02:40,930 So now that my object has a summary function that returns a string it once again qualifies as being 33 00:02:40,960 --> 00:02:47,580 a vehicle so if I go back down to the bottom of the file again that era has now gone away and now inside 34 00:02:47,880 --> 00:02:52,530 of my print vehicle function rather than trying to pull off all these different properties one by one 35 00:02:52,590 --> 00:03:01,070 I can instead rely upon that summary function so I can call something like console dot log vehicle dot 36 00:03:01,250 --> 00:03:02,630 summary like so 37 00:03:05,610 --> 00:03:05,830 all right. 38 00:03:05,860 --> 00:03:07,490 So again just two notes here. 39 00:03:07,540 --> 00:03:11,430 First off we can use any type inside of our interface definition we want. 40 00:03:11,500 --> 00:03:14,300 We are not limited just to permanent values. 41 00:03:14,320 --> 00:03:19,720 Second important note is that inside of our interface definition we can express functions inside there 42 00:03:19,720 --> 00:03:23,710 as well so let's take a quick pause right here in the next video. 43 00:03:23,720 --> 00:03:28,430 I want to share two more important notes with you around basic syntax of interfaces so quick pause and 44 00:03:28,430 --> 00:03:30,070 I'll see you in just a minute.