A copy of the JavaScript functions in the head element:
// sample-9-4-class-functions.js

// constructor for Student objects, with setGrade method
function Student (firstName, lastName, id)
  {
  this.first = firstName;
  this.last  = lastName;
  this.id    = id;
  this.grade = "";
  this.setGrade = SetGrade;
  }

// method to set the grade property
function SetGrade( newGrade )
  {
  this.grade = newGrade;
  }

// method to build a string with the name reversed
function ReversedNameString()
  {
  return ( this.last + ", " + this.first + " " + this.middle ) ;
  }
      
A copy of the JavaScript in the body element:
// sample-9-4-class.js
// Extend an class sample

// create two objects in the student class
var fred = new Student("Fred", "Schmidt", 123456);
var mary = new Student("Mary", "Jones", 654321);

Student.prototype.reversedNameString = ReversedNameString;
Student.prototype.middle = "";

mary.middle = "Ann";

document.write( fred. reversedNameString () );
document.write("<br />");
document.write( mary.reversedNameString() );
document.write("<br />");