String.prototype.padLeft / String.prototype.padRight
Claude Pache
claude.pache at gmail.com
Mon Nov 16 13:27:59 UTC 2015
> Le 16 nov. 2015 à 09:18, Jordan Harband <ljharb at gmail.com> a écrit :
>
>
> 3) The naming is set in stone - `reduceRight` sets a clear precedent that "right" is "the length minus one",
True, but `.reduceRight` is for arrays, for which there does not exist a strong natural notion of "right-to-left" that has nothing to do with order.
> and has no relationship to the visual direction, and based on `trimLeft` and `trimRight`, which are already implemented in basically all browsers Thus, in ECMAScript, "left" is not considered a visual direction but rather a synonym for "start" and "index 0". The naming is also mentioned here: https://github.com/tc39/proposal-string-pad-left-right#naming <https://github.com/tc39/proposal-string-pad-left-right#naming>
When we have two existing competing precedents in the language (left/right vs. starts/ends), why choose to be consistent with the bad one instead of the good one?
A plausible argument for keeping `left/right` would be that other languages have `padLeft`/`padRight`. However, a simple google search shows that better-named `padStart` and `padEnd` are also in use.
—Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151116/c46c7c79/attachment.html>
More information about the es-discuss
mailing list