I want to use integer %00d
in javascript using jquery.
like that integer 8 will print output like 008.
In C printf("%00d", 8);
How about javascript?
How to solve it problem? Thanks any reply.
I want to use integer %00d
in javascript using jquery.
like that integer 8 will print output like 008.
In C printf("%00d", 8);
How about javascript?
How to solve it problem? Thanks any reply.
If you'd like a library, you should give sprintf a try.
If not, there are several interesting options in this question in SO. Particularly, I liked this solution:
// First, checks if it isn't implemented yet.
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
"{0} is dead, but {1} is alive! {0} {2}".format("ASP", "ASP.NET")