Transcript from the "__proto__" Lesson
>> So we realize, this approach that produces our objects towards one in user1, one in user2, it creates a big issue. Our functions are yeah, hooray, are available right on our objects, success. But that she got copies of them, they're all the same function And if you've got a thousand functions, you've got a copy of each of those functions on every single user object.
[00:00:27] This is gonna take millions of lines of memory, when we don't need. We just have a single version of that function. What would be our solution? Store our increment function In just one object as imagined we could sort of store it in just one object let's call it I don't know store or function let's call it function store and in that one object supposed there we were to.
[00:01:30] Store the increment function in just one object and have the interpreter When we do something like User 2 dot increment, look up at User 2, there's no increment function on it. We don't want a unique increment function on User 2 objects. But instead look up to this object shared to check if increments there.
[00:01:53] It is. And run that functionality. That's going to be our, what about that as an approach? Approach, all together if all you believe good approach?
>> Controlling personality. All right. Good but how can we make that link? What's that famous word? People like to shout out words and mine might not be right Or how might we make that link?
>> Bond, okay, is having a bond, what sort of bond?
>> A reference.
>> Reference, what's the special word?
>> It's got as many words as you like.
>> Back pack.
[00:03:15] The single version. We're going to walk through this line by line. See it all play out in full. But know that's fundamentally what we're doing. We're going to somehow make a bond to a shared function store in which all the functions that we'd want to have available on user two.
[00:03:31] We want to be able to do this dot increment. That's always our goal. But we don't want to have the increment function on user two. So we're going to use a special prototypal nature, a special bonus feature of Java. I think this is the last one. This is the last true feature of Java Script that lets us, when we access user two and don't find increments.
[00:03:52] Go look at this function store through this special hidden bond. You see how this hidden bond works, but first, let's walk through this code line by line.