Javascript Inheritance

instanceof operator The instanceof operator determines if an object was instantiated as a child of another object, returning true if this was the case.

Inheritance by Prototypes The prototype of an object can be used to create fields and methods for an object. This prototype can be used for inheritance by assigning a new instance of the superclass to the prototype.

function CoinObject()
{
 this.value = 0; 
 this.diameter = 1;
}
 
function Penny()
{
 this.value=1;
}
Penny.prototype = new CoinObject();
 
function Nickel()
{
 this.value=5;
}
Nickel.prototype = new CoinObject();

Inheritance by functions

function CoinObject()
{
 this.value = 0; 
 this.diameter = 1;
}
Submit an Idea
  Thank you for your valuable feedback.
Your E-mail (optional):
Select Option:
Description:
 
Feedback
Your Name / email address
Feedback as
Your feedback
close
Quickly sign in with:

Create a FATALWEB account here:

First name:

Last name:

E-mail address:

Join Fatalweb

Already have a fatalweb account? Log in here