function ClassA() { // Superclass defines a string and a function as statis ClassA.prototype.str1 = "String 1 from ClassA
"; ClassA.prototype.func1 = function() { document.write("Function 1 from Class A
"); }; } function ClassB() { // Subclass defines a string as statis ClassB.prototype.str2 = "String 2 from ClassB
" } // ClassB inherits all members of ClassA ClassB.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 superclass var instance = new ClassB(); // Write member variables and functions document.write(instance.str1); document.write(instance.str2); instance.func1();