Most Wanted JavaScript String.prototype Extensions
Posted on September 30th, 2007 by Jans
This is the list of 10 JavaScript String.prototype extensions.
This extension adds trim() function:
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,Չ۪); }
//test trim
test = ‘ testing trim ‘;
document.write (’”’ + test.trim() + ‘”’);
This extension splits the string by given separator and returns an array with trimmed items. It uses the trim() extension above:
[…]
Filed under: JavaScript | No Comments »