02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoPrevious Video

Adding methods to built in Objects

<p>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.</p> <p>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.</p> <p>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.</p>

Call and Apply

Functions are objects. There probably the most primitive type in JavaScript. To show case this we will create an example working with scope.

08:55

Creating And Working with Methods

A method is a function that is owned by an object. We will create our method and now it is available to all instances of the object type we added this prototype.

08:51

Creating and Working with Properties

Functions are objects. There probably the most primitive type in JavaScript. To show case this we will create an example working with scope.

02:33

Adding methods to built in Objects

How do JavaScript prototypes work? Lets see them in action by showing you how you can add prototype methods by adding new methods to built in objects such as the Array object.

04:32

Inheritance

Extending the Built in JavaScript Objects using inheritance and the prototype.

12:43