Tuesday, December 29, 2015

set trim function for strings

       function setTrim()
        {
            if (typeof String.prototype.trim !== 'function')
            {
                String.prototype.trim = function()
                {
                    return this.replace(/^\s+|\s+$/g, '');
                }
            }
        }

No comments:

Post a Comment