JavaScript: The Hard Parts, v2

Prototype Chain Review

Will Sentance

Will Sentance

JavaScript: The Hard Parts, v2

Check out a free preview of the full JavaScript: The Hard Parts, v2 course

The "Prototype Chain Review" Lesson is part of the full, JavaScript: The Hard Parts, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Will reviews the last few sections, and how they relate to the standard way of object creation in the proceeding sections.


Transcript from the "Prototype Chain Review" Lesson

>> Will Sentance: So to summarize solution two back to the core of the goal here. Like I gave those bonus pieces there for all of us just, intriguing things. Using the prototype chain, using JavaScript prototype or feature that user one and user two, go access from when they were created inside of user creator with the order to create which gave their object a bond to use a function store.

When I ran user one.increment and did not find it, the increment functionality of user one, did I panic? No, I headed up the proto reference at the prototype chain to the user function store where I found increment, and I run it, problems with this? No problems, it's beautiful.

It's a sort of Star Wars with you in your interview said to your interviewer, I prefer because I want more fine grained control over my writing of my oxygen that I tend to try and follow this approach. And they're gonna go, they're gonna think the worst. But, at the same time, they're gonna go, impressive.

I better say I agree. They're gonna go, yes, me too, yes. They're not saying is the right way, it's certainly not standard. And I would not be suggesting you use this but it's gonna turn out to be the answer to what's really happening when we do use the standard way of achieving this same goal.

Cuz the standard way, solution three and four, increasingly just solution four, behind the scenes is doing all this here. And that means if you've gotta debug, you've gotta understand it. That means if you wanna interview and answer the question what's the new keyword actually doing behind the scenes, you got to know all this stuff.

And I will say this, if you're writing, if once you start thinking in this paradigm in this way of thinking, you start structuring everything you do as object containing the data that's pertinent to that feature and its associated functionality. You solving have users and admins, and moderators, and quiz questions, and league tables, and even the game application itself.

All is just a collection of data associated with that but even the game board, the dimensions of the game board and then functionality related to that game board. I use something for everything in this way. So you start writing a lot of these functions that produce an object, sometimes just one object with just a sort of functions and you only ever have one of them, you just think in this manner from now on.

So I guess if you're always creating a little object inside, always making your connection to a store of functions, always returning that object out like, I guess it might be nice to have a way of saving yourself during that process every time. But it is super sophisticated this way, but it isn't standard.

So we're now gonna see in solution three the more standard way introducing the keyword, they're all that makes the hard work, its new.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now