Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

Modifying Objects

You can define a new method for any existing class by using its prototype property. Number.prototype.toHexString = function () {     return this.toString(16); }; var iNum = 15; alert(iNum.toHexString());