String#trim(chars)

Michael DeByl michael.debyl at gmail.com
Mon Jun 19 12:51:57 UTC 2017


Generally `trim()` will only operate on the start and end of the strings (also why `trimLeft()` and `trimRight()`.

All that needs to be done is allow specifying a string or array of characters to trim as an argument – which should not break anything as the `trim()` method currently accepts nothing. If nothing specified, use [\r, \n, \t, ‘ ‘] – or whatever it currently does as to once again not break anything.

As a sidenote; traditionally `trim` will use text transforms first from the start, and then from the end of the string. I’m not sure in JS if a regex is faster, or if it even matters overall.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170619/cefd570f/attachment.html>


More information about the es-discuss mailing list