I\'ve read this question about javascript trim, with a regex answer.
Then I expect trim to remove the inner space between Hello and World.
Probably because you forgot to implement the solution in the accepted answer. That's the code that makes trim() work.
trim()
update
This answer only applies to older browsers. Newer browsers apparently support trim() natively.