The question says it all; JS doesn\'t seem to have a native trim() method.
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