Tagged: prototype


Javascript String Prototype Extensions

Most variables in JavaScript represent themselves internally as strings. The String class in JavaScript contains a number of handy methods, but many commonly-used functions which are available in other languages, such as the trim()...


Javascript string method prototype ex. Remove(), ReplaceAll(), Trim()

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, “”); }; String.prototype.replaceAll = function(item,replacewith) { var s = this; while (s.indexOf(item) >= 0) s = s.replace(item, replacewith); return s; } String.prototype.remove = function(item) { return this.replaceAll(item, “”);...