trim = (str) => str.trim ?
  str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '')
Trim excess whitespace off the beginning and end of a string

@param {String} str The String to trim

@returns {String} The String freed of excess whitespace