Object Oriented JavaScript Tutorial

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