As far as I understand, you just copied its prototype. Note that various structures have ways to extend and extend javascript classes, which may be better. I have not tested this
var IPAddress = function() {};
IPAddress.prototype = new String;
IPAdress.prototype.getFoo = new function () {}
source
share