Pad functions for Javascript

This snippet will give you the pad functions (padRight, padLeft) for javascript.

Sample Javascript

String.prototype.padLeft = function(length, character) {
	var text = this.valueOf();
	var character = character || " ";
	while (text.length<length) {
		text = character + text;
	}
	return text;
};

String.prototype.padRight = function(length, character) {
	var text = this.valueOf();
	var character = character || " ";
	while (text.length<length) {
		text = text + character;
	}
	return text;
};

Please rate this snippet