Input type number
by NunoMira
JavaScript
//HERRANÇA EM JAVASCRIPT
//Declaring our Animal object
var Animal = function ()
{
alert('construtor Animal');
var name = 'batatas';
this.getName = function ()
{
return name;
}
this.setName = function (newName)
{
name=newName;
}
return this;
};
//Declaring our Dog object
var Dog = function ()
{
alert('construtor Dog');
Animal.call();
var private = 42;//private variable here
this.setName('boby');
this.bark = function ()
{
return 'MEOW';
}
return this;
};
var MyDog = function ()
{
Dog.call();
this.setName('my boby');
this.bark = function ()
{
return this.__proto__.bark()+" arf";
}
return this;
};
Dog.prototype = new Animal(); //Dog extends animal
MyDog.prototype = new Dog(); //MyDog extends animal
alert('antes');
var toubini = new MyDog(); //Creating an instance of Dog.
alert('depois');
alert(toubini.bark());