JavaScript Classes
You define a class using an object constructor.
function Song(name, year, timesPlayed) { this.name = name; this.yearRecorded = year; this.timesPlayed = timesPlayed; }You then create objects of this class, using the constructor...
var WildThing = new Song("Wild Thing", 1966, 30); var MaggotBrain = new Song("Maggot Brain", 1972, 35);Characteristics of objects can then be brought up by evoking a method...
Song.prototype.announce = function(){ alert("The next song to be played is" + this.name); }A prototype extends a class with additional functionality that is available for all objects of that class.