Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

Define a method after object instantiation

It is possible to define a method for a type of object after the object has already been instantiated. var o = new Object; Object.prototype.sayHi = function () {     alert("hi"); }; o.sayHi();