I found similar test results regarding this by slevithan:
http://blog.stevenlevithan.com/archives/faster-trim-javascript

But feel free to change it to whatever works for you.