1
00:00:00,848 --> 00:00:01,784
There's something interesting going on

2
00:00:01,784 --> 00:00:03,997
with our person objects that you may not

3
00:00:03,997 --> 00:00:05,862
have noticed just yet. After we create

4
00:00:05,862 --> 00:00:10,283
this Jim object down here, let's display

5
00:00:10,283 --> 00:00:13,112
it. So there's something notable missing

6
00:00:13,112 --> 00:00:15,363
here. We have this fullName getter, and so

7
00:00:15,363 --> 00:00:17,272
there's a fullName property on our Jim

8
00:00:17,272 --> 00:00:19,267
object, but it's not showing up when we

9
00:00:19,267 --> 00:00:21,631
display the object, that's because when

10
00:00:21,631 --> 00:00:24,395
you create a getter, it is created with

11
00:00:24,395 --> 00:00:26,908
enumerable set to false. Generally this

12
00:00:26,908 --> 00:00:29,072
isn't a big deal because it's not too

13
00:00:29,072 --> 00:00:31,102
often that you iterate over the keys of an

14
00:00:31,102 --> 00:00:32,995
object, but if you needed to and you

15
00:00:32,995 --> 00:00:35,212
wanted your getters to show up, you'd need

16
00:00:35,212 --> 00:00:38,355
to set this getter property to enumerable

17
00:00:38,355 --> 00:00:40,239
first. Unfortunately there isn't a good,

18
00:00:40,239 --> 00:00:42,725
clean way to do that with classes, so

19
00:00:42,725 --> 00:00:43,867
we'll have to revert back to our

20
00:00:43,867 --> 00:00:47,539
Object.defineProperty method. We'll do

21
00:00:47,539 --> 00:00:51,430
that just outside of our Person class. Now

22
00:00:51,430 --> 00:00:52,948
which object are we going to define this

23
00:00:52,948 --> 00:00:55,433
property on? The question is where does

24
00:00:55,433 --> 00:00:58,042
that fullName property exist? Well it's

25
00:00:58,042 --> 00:01:00,925
not on the Person class itself, but it's

26
00:01:00,925 --> 00:01:03,152
on the Person class' prototype. Yep,

27
00:01:03,152 --> 00:01:05,203
classes have prototypes, just like

28
00:01:05,203 --> 00:01:07,092
functions do, and that's an interesting

29
00:01:07,092 --> 00:01:10,761
thing to note. Getters and setters live on

30
00:01:10,761 --> 00:01:12,938
the prototype, whereas other properties

31
00:01:12,938 --> 00:01:16,363
like firstName, lastName, and age live on

32
00:01:16,363 --> 00:01:18,662
the Person object instances. That makes

33
00:01:18,662 --> 00:01:20,408
sense when we really think about it. There

34
00:01:20,408 --> 00:01:22,965
is nothing stateful about getters and

35
00:01:22,965 --> 00:01:24,473
setters, they're really just functions, so

36
00:01:24,473 --> 00:01:26,740
they can live on the prototype, but the

37
00:01:26,740 --> 00:01:28,082
other properties like firstName and

38
00:01:28,082 --> 00:01:30,917
lastName contain state that change from

39
00:01:30,917 --> 00:01:33,055
instance to instance, so those need to be

40
00:01:33,055 --> 00:01:35,603
instance properties. So the fullName

41
00:01:35,603 --> 00:01:38,541
getter is on the prototype, so we'll

42
00:01:38,541 --> 00:01:41,518
modify the person.prototype, and we want

43
00:01:41,518 --> 00:01:45,456
to change the fullName property and set it

44
00:01:45,456 --> 00:01:48,699
to enumberable: true. There, now when I

45
00:01:48,699 --> 00:01:50,718
save this because we're displaying Jim

46
00:01:50,718 --> 00:01:53,448
here, you can see fullName shows up here

47
00:01:53,448 --> 00:01:56,245
in our browser, so our fullName property

48
00:01:56,245 --> 00:01:58,128
is now enumerable. And of course you can

49
00:01:58,128 --> 00:01:59,333
do this with the other property

50
00:01:59,333 --> 00:02:02,018
descriptors too, like configurable and

51
00:02:02,018 --> 00:02:06,000
writable. Now let's take a look at inheritance with classes.

