I am trying to create/extend the node.js util.format function so that it can be used as a prototype (e.g.: "Hello %s".format("World")). However, I have been unsuccessful trying it. I have tried the following formats to no avail:
String.prototype.format = function(){return util.format(this, arguments)};
and
String.prototype.format = function(){return util.format.apply(this, arguments)};
and also
String.prototype.format = function(args){return util.format(this, args)};
None of these work. Do you have any idea what I am doing wrong?
Thanks, Manuel