Check out a free preview of the full JavaScript: The Hard Parts of Object Oriented JavaScript course:
The "Prototype Tracing" Lesson is part of the full, JavaScript: The Hard Parts of Object Oriented JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

Will traces the diagramed solution using called functions on the instantiated paidUser, ensuring that functions are specific to the paid user type, but are available to all users.

Get Unlimited Access Now

Transcript from the "Prototype Tracing" Lesson

[00:00:00]
>> Will Sentance: Let's do our checks people, let's do our checks. Do we have everything that we need? Do we have both our functions that are specific to a paid user type and our function that's specific, not specific but available to all users? Let's do our check. Raise your hand, if you wanna do the lookup check.

[00:00:20] David, you're up man. Give me a second, paiduserone.increase balance.
>> Will Sentance: Let's do it. Where's paid user one?
>> Speaker 2: Global memory.
>> Will Sentance: There it it.
>> Speaker 2: And inside of it.
>> Will Sentance: Is there a property increase user balance?
>> Speaker 2: No.
>> Will Sentance: Which is bad as note.
>> Speaker 2: Go to proto which goes to the paid user creator and the prototype.

[00:00:46]
>> Will Sentance: Yeah, the prototype which finds the, excellent. It's simple as that. Look, note all that all this code is all just trying to get these objects to have access to a collection of functions, and then those collection of functions have access to another collection of or let's see if it does have access.

[00:01:01] Let's do paid user, so this was a success, lets do paiduserone.sayname, okay, David, take it away again.
>> Speaker 3: Yep, paid user one and global memory.
>> Will Sentance: Perfect.
>> Speaker 3: Checks for sayname, it doesn't find it.
>> Will Sentance: Yeah.
>> Speaker 3: Follows it's proto-
>> Will Sentance: Just give me a second I'm gonna change color so use orange.

[00:01:24] So, yeah, doesn't find it. Follows the proto up to-
>> Speaker 3: Paid user creator's prototype is there, nothing. So then it goes through its proto up to user creator, checks its proto for same name.
>> Will Sentance: Not proto checks, its prototype object. Does it find same name?
>> Speaker 3: Yes, it does.

[00:01:41]
>> Will Sentance: It does. We have access to functions that are specific to a paid user one, a paid user two, a paid user ,100 and we have access to functions that are available to all users, but also still available through that chain up. As to our specific paid user one.

[00:02:05] Go ahead, Eric.
>> Eric: So we have lost reference to Paid Name. The parameter Paid Name is [CROSSTALK].
>> Will Sentance: Yeah, yeah, yeah, but that's not a problem. I called it Paid. We have the parameter, which is used to temporarily hold.
>> Eric: Right.
>> Will Sentance: A list. Before we stuck it on the object, under the label name.

[00:02:24]
>> Eric: Right.
>> Will Sentance: Yeah, yeah.
>> Speaker 5: But it's not part of the global anymore?
>> Will Sentance: No, well, it's definitely not available. No, no, no.
>> Speaker 5: Right.
>> Will Sentance: Everything inside this execution cord has been deleted except for the object we return out.
>> Speaker 5: And it never got copied to this, so it's gone.

[00:02:35]
>> Will Sentance: Yeah, well, we held on to the list though, cuz we stuck it on name. Remember, when we went through through music raise a call exactly, but we don't care that it's called paid name. We wanted it's parameter to be named. I called it paid name to make sure it's really clear that we have paid name here.

[00:02:54] But in the end it gets passed in and becomes name. Inside userCreator and stuck on the object as name. All right, here we go, people. We are almost there, final version.