August 2016
Beginner to intermediate
847 pages
17h 28m
English
First, we will create a constructor function in JavaScript and define properties and methods in its prototype. Then, we will take advantage of prototype-based inheritance in order to create objects that specialize the behavior defined in the baseline prototype. We will override methods and properties.
Now it is time to code objects in JavaScript. The following code defines the Animal empty constructor function in JavaScript, followed by the declaration of properties and functions for the Animal prototype:
function Animal() {} Animal.prototype.numberOfLegs = 0; Animal.prototype.pairsOfEyes = 0; Animal.prototype.age = 0; Animal.prototype.printLegsAndEyes ...