String.prototype.trimRight/trimLeft

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Mon Mar 16 22:22:10 UTC 2015


Hi,

Just got a question why don't we polyfill `trimLeft` and `trimRight` for
strings, and have only `trim` (and the answer is -- because it's not part
of ES5/ES6).

Just thinking could it be a valid cases when a dev may want to trim only
form right still keeping e.g. the precalculated padding on the left (seems
legit)?

MDN mentions them [1], [2], though as non-standard. What stopping both
methods to be included?

[1]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimLeft
[2]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight

Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150316/0ae32565/attachment.html>


More information about the es-discuss mailing list