_.trim

❗️Lodash onlyRemoves the leading and trailing whitespace characters from a string.

  1. // Lodash
  2. var result = _.trim(' abc ')
  3. console.log(result)
  4. // output: 'abc'
  5.  
  6. // Native
  7. var result = ' abc '.trim()
  8. console.log(result)
  9. // output: 'abc'

Browser Support for String.prototype.trim()

ChromeEdgeFirefoxIEOperaSafari
5.0 ✔3.5 ✔9.0 ✔10.5 ✔5.0 ✔