String strip() for JavaScript? [duplicate]

What’s a clean and efficient JavaScript implementation to strip leading and trailing spaces from a string?

For example:

" dog"

"dog "

" dog "

" dog "

all get turned into

"dog"

8 Answers
8

Leave a Comment