Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- output:
- flappie flappie
- egg layed
- swimmy swimmy
- walkie walkie
- eww, worms
- nom, nom
- swimmy swimmy
- swimmy swimmy
- nom, nom
- undefined
- */
- function Bird(){
- this.layegg = function (){
- console.log("egg layed");
- }
- this.walk = function(){
- console.log("walkie walkie");
- }
- }
- Bird.prototype.eatWorms = function(){
- console.log("eww, worms");
- }
- function Penguin(){
- Bird.call(this);
- this.swim = function(){
- console.log("swimmy swimmy")
- }
- }
- Penguin.prototype = Object.create(Bird.prototype);
- function Duck(){
- Bird.call(this);
- this.fly = function(){
- console.log("flappie flappie")
- }
- }
- duck1 = new Duck();
- duck1.fly();
- duck1.layegg();
- penguin1 = new Penguin();
- penguin1.swim();
- penguin1.walk();
- penguin1.eatWorms();
- Bird.prototype.eatFish = function(){
- console.log("nom, nom");
- }
- penguin1.eatFish();
- penguin1.swim();
- penguin2 = new Penguin();
- penguin2.swim();
- penguin2.eatFish();
Add Comment
Please, Sign In to add comment