software-mariodiana
12/17/2014 - 9:26 PM

Example of why and how to add functionality to a JavaScript object. See: http://stackoverflow.com/a/2308157

Example of why and how to add functionality to a JavaScript object. See: http://stackoverflow.com/a/2308157

// IE 8 is a "special needs" browser.
if(typeof String.prototype.trim !== 'function') {
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g, ''); 
    }
}