Ok, I tested modifying the object, instead of the class. In other words, create your class, then define the object by declaring, var myObject = new Class(); Once the object has been created, THEN can you modify it's methods. However, you cannot modify methods of the browser's existing objects and classes, such as the document object or the Element class. Anyway, here's how I do it:
//Construct our class
function MyClass(arg1) {
//Make your arguments accessible to outside functions
this.firstArgument = arg1;
this.methodA = function() {
alert(this.firstArgument);
}
}
//Define the object
var myObject = new MyClass("foo");
//Create a function to change the object instead of the class
function changeMethod() {
myObject.methodA = function() {
alert(myObject.firstArgument + " " + "bar");
}
}
//Returns "foo":
myObject.methodA();
changeMethod();
//Returns "foo bar":
myObject.methodA();