Trim whitespace |
---|
To trim whitespace from the edges of a string, use String.prototype.trim: “ some whitespaced string “.trim(); // “some whitespaced string” Many JavaScript engines, but not Internet Explorer, have implemented non-standard trimLeft and trimRight methods. There is a proposal, currently at Stage 1 of the process, for standardised trimStart and trimEnd methods, aliased to trimLeft and trimRight for compatibility. // Stage 1 proposal “ “ this is me this is me “.trimStart(); // “this is me “ “.trimEnd(); // “ this is me” // Non-standard methods, but currently implemented by most engines “ “ this is me this is me “.trimLeft(); // “this is me “ “.trimRight(); // “ this is me” |
Published: | December 31, 2022 |
Author: | admin |
Category: | JavaScript/jQuery How to |
Views: | 16 |
This article was posted in JavaScript/jQuery How to. Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.
|
|