Originariamente inviato da nosferatu_net
codice:
String.prototype.nf = function(c) {
	var r = this;
	return r.length < c ? ("0" + r).nf(c) : r;
}
Ah, sì, adesso che la vedo, la funzione si può scrivere anche così risparmiando una riga di codice:
codice:
String.prototype.nf = function(c) {
	return this.length < c ? ("0" + this).nf(c) : this;
}