Comments (8)
This has already been decided. trimLeft
and trimRight
are in Annex B for legacy reasons, and trimStart
and trimEnd
are the proper names. The same logic applied to padStart
and padEnd
.
The start of the string is index 0, and the end is index length - 1
. "Left" and "right" are problematic because they refer to display, and JS-the-language does not concern itself with display - for example, Unicode Byte Order Markers are not treated specially.
from proposal-string-left-right-trim.
@ljharb I just realize that my problem is I never know trimLeft/trimRight
already implemented in all browsers. My fault, thank you.
from proposal-string-left-right-trim.
I'm curious that why padLeft/padRight/contains
not in Annex B if 'trimLeft/trimRight` will.
from proposal-string-left-right-trim.
@hax there is no padLeft
, or padRight
, or contains
- those things simply don't exist and never have (although they all almost did). There is padStart
, padEnd
, and includes
.
from proposal-string-left-right-trim.
@ljharb I remember padLeft/padRight/contains
are names in the old draft and many polyfill old versions use these names. Maybe padLeft/padRight
never exist in engines, but at least contains
existed in FF 17~39, Chrome 30~39 (under flag), Node 0.12.x (with --harmony), and I happened meet a bug in a Node.js project related to it.
from proposal-string-left-right-trim.
Annex B is only for legacy compat; something that never existed without a flag never needs to exist without one.
People using polyfills of nonstandard features are taking a risk, and they need to be responsible to update them when the standard changes - otherwise they're just mutating builtins, which is a horrific practice for the web.
from proposal-string-left-right-trim.
@ljharb But string.prototype.contains
existed in FF 17~39 without flag.
from proposal-string-left-right-trim.
Sure. But to be a web compat issue, it had to exist in the majority of browsers at least. Existing in only one browser doesn't matter at all, as any code that relied on it was already broken for the rest.
from proposal-string-left-right-trim.
Related Issues (8)
- Please transfer repository to tc39 HOT 1
- Reviews for stage 3 sign off HOT 8
- Have we considered a paramater to the trimX() functions similar to C# usage. HOT 2
- Advance to stage 4 HOT 2
- Add trimStart/trimEnd HOT 1
- [Q] `String#{trimStart, trimEnd}` and `String#{trimLeft, trimRigth}` equality HOT 7
- Todo List HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-string-left-right-trim.