How to trim a string in Javascript

This is the best trim function for JavaScript that I found while surfing the net.

var trimmed = str.replace(/^\s+|\s+$/g, '') ;
source

0 comments: