Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Cat(name)
- {
- this.name = name;
- }
- Cat.prototype.voice = function ()
- {
- console.log("Hello, my name is: " + this.name);
- }
- var cat1 = new Cat("Murzik");
- cat1.voice();
- function HomeCat(name, address)
- {
- Cat.call(this, name);
- this.address = address;
- }
- HomeCat.prototype = Object.create(Cat.prototype);
- HomeCat.prototype.constructor = HomeCat;
- HomeCat.prototype.voice = function ()
- {
- Cat.prototype.voice.call(this);
- console.log("I'm from: " + this.address);
- }
- var cat2 = new HomeCat("Murka", "Kiev");
- cat2.voice();
- var cat3 = new HomeCat("Rocky", "Stambul");
- cat3.voice();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement