Next freebie in 28 Hours*
The best way to see how prototypes work are by seeing them and interacting with them. To do that we will revisit a variable we created in an earlier video. We will now create the variable again using prototypes. We then will look at the two as now we got two variables with the exact same name. So how can this work and how is it that its not a conflict. This is exactly the point where we go back to the meaning of this and how it works and relates to variables that are defined in the constructor verses ones that are created using the prototype.
One of the most important things we will learn here is the importance of scope. You will see that over and over we mention and talk about the scope. This is because the most important concept in OOP is scope once you get it and really understand how it works in one language you will understand it in any language.
When we refer to something using the this command we are actually refereeing directly to the object itself and thus when we create a variable that is tied directly to the this we are actually creating a local variable or “private” variable that only is available to this object while creating variables using the prototype we are actually adding the variable to every object of that type and and prototype that inherits from this one. There are a few other goodies that we talk about in this section so don't skip it, very critical.
Have a question but don't want to ask it publicly? If you are a prime member just ask right here and we will get back to you within 48 hours. Not prime yet? no worries you can ask publicly below.