`trimStart` and `trimEnd` are better-named versions of the very very long-existing `trimLeft` and `trimRight`, which lack this ability, along with ES5's `trim`.
It wouldn't make sense for these three to differ. It certainly seems like a potential language proposal to add a string argument to all three; however, at what point is that reimplementing `string.replace(/^(foo)+/, '')`, `string.replace(/(foo)+$/, '')`, and `string.replace(/^(foo)+|$(foo)+$/, '')`? How common is the use case to trim matching substrings off of the ends of a string? (the use cases for padding were quite common) On Sun, Jun 23, 2019 at 12:14 AM Jacob Pratt <jhpratt...@gmail.com> wrote: > `String.prototype.padStart` and `String.prototype.padEnd` accept the > string to pad with as their final parameter. Is there any particular reason > `String.prototype.trimStart` and `String.prototype.trimEnd` don't do the > same? It would be nice to have a parallel, such that `'foo'.padEnd(10, > 'bar').trimEnd('bar') === 'foo'`. > > References: > - https://github.com/tc39/proposal-string-pad-start-end > - https://github.com/tc39/proposal-string-left-right-trim > > Jacob Pratt > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss