Inheritance
In the last section of this training we adding dynamically methods to the built in objects. In this next section we will extend the functionalities of the built in objects by creating a new sub object. This object would then be linked to the original object. We continue from where we last left off and add into the mix the capability to extend the class using inheritance. In javascript its not exactly inheritance as you would see in a standard oop language such as Java/ActionScript3 in JavaScript there is a chain and as such we can disconnect or reconnect chains. In our case we will create a totally new object and then link it to an existing Object type. In our case we will create an advanced Array called ArrayExt that extends the functionalities of the Array.
We will add a few new methods to our new array. And text it out. We broach the topic of encapsulation. Encapsulation in its essence is the idea of what variables are visible if we loop through an object while what variables are hidden. The default behavior of an Array is all the new methods/properties are enumerable while built in methods/properties are not. Don't worry to much about the strict definition of encapsulation all you want to know is a variable loop-able or not. If that sounds a bit unclear it means its time to jump into our video so we can expand on this topic.
Ready to Level Up Your Skills?
Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!
Enroll Now for Free!