function ClassA() { // Superclass defines a string and a function as statis ClassA.prototype.str1 = "String 1 from ClassA<br />"; ClassA.prototype.func1 = function() { document.write("Function 1 from Class A<br />"); };}function ClassB() { // Subclass defines a string as statis ClassB.prototype.str2 = "String 2 from ClassB<br />"}// ClassB inherits all members of ClassAClassB.prototype = new ClassA();// Add more stuff to subclass B after changing its prototype// because otherwise class instance stuff will be replaced when changing its// prototype.// Create an instance of ClassB that has inherited from superclassvar instance = new ClassB();// Write member variables and functionsdocument.write(instance.str1);document.write(instance.str2);instance.func1();