Javascript String print()
// Implementation of the sprintf-functionality // Example: "abc test: %01.2f".print(123.1); String.prototype.print = function() { var arr = new Array(); arr[0] = this;// w ww . j a v a 2 s. c o m for (var i=0; i<arguments.length; i++) { arr.push(arguments[i]); } response.write(require("sprintf").sprintf.apply(this, arr)); return this; }; exports.print = function (mixed) { if (arguments.length==1) { response.write(mixed); } else { response.write(require("sprintf").sprintf.apply(this,arguments)); } return this; };