Trim whitespace
suggest changeTo remove whitespace from both ends of a string, use String.prototype.trim():
" some whitespaced string ".trim(); // "some whitespaced string"
Use trimStart() or trimEnd() to remove whitespace from only one end. trimLeft() and trimRight() are the same functions under older names.
" this is me ".trimStart(); // "this is me "
" this is me ".trimEnd(); // " this is me"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents