A copy of the JavaScript functions in the head element:
// sample-9-3-extend-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-3-extend.js
// extend sample

var mary = new Student("Mary", "Jones", 654321);

mary.middle = "Ann";

mary.reversedNameString = ReversedNameString;

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