This very simple example illustrates how the abstract object FullName extends (is derived from) the abstract object Name, thus implementing inheritance, i.e. FullName is-a Name. The code is:
In the document head is the constructor,
function Name(first){The document body contains the following script with the constructor of the abstract object FullName which is specified as being a subclass of Name, by the prototype property of the Core object object, in the instruction following the constructor.
this.first=first
this.nickName=" 'JavaScript Hotshot' ";
}//end Name
function FullName(last){
this.last=last;
}//Derive FullName from the "parent" abstract object Name, implementing inheritance.
FullName.prototype=new Name; //Inheritance makes first and nickName properties of FullName.//This unusual construct would have to be called "object extension"!
FullName.prototype.salutation = "Hi there, ";//Instantiate the real object "you" from the abstract object FullName.
you=new FullName;//Prompt for input and reply.
you.first=prompt("Enter your first name:");
you.last=prompt("Enter your last name:");
document.write(you.salutation + you.first + ". Your new name is " + you.first + you.nickName + you.last);
The output of this script is: