Search code examples
javascriptjquerystringtrim

How to trim() white spaces from a string?


JavaScript doesn't seem to have a native trim() method. How can I trim white spaces at the start and end of a string with JavaScript?


Solution

  • I know this question is ancient but now, Javascript actually does have a native .trim()

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim