Define a method after object instantiation : prototype : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » prototype »

 

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();







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» prototype