Closed
Description
Ported from OS#18780560
Stage 3 Proposal: https://github.com/tc39/proposal-string-left-right-trim
We already have implementations of trimLeft and trimRight, so we simply need to add trimStart and trimEnd as aliases to those.
>es --tags jsvu-web -is E:\work\bugs\19h1\trimStart-trimEnd\trimStart-trimEnd.js
## Source
let stringToTrim = ' hello '
function trimIt(trimmerFn) {
return '.' + trimmerFn.call(stringToTrim) + '.';
}
function has(funcName) {
let doesHave = String.prototype.hasOwnProperty(funcName);
let doesHaveString = doesHave ? '++ yes ++' : '-- NO --'
print(`has ${funcName}? ${doesHaveString}`);
if (doesHave) {
print(trimIt(String.prototype[funcName]))
}
}
has('trimLeft')
has('trimRight')
has('trimStart')
has('trimEnd')
#### jsvu-ch
has trimLeft? ++ yes ++
.hello .
has trimRight? ++ yes ++
. hello.
has trimStart? -- NO --
has trimEnd? -- NO --
#### jsvu-jsc, jsvu-sm, jsvu-v8
has trimLeft? ++ yes ++
.hello .
has trimRight? ++ yes ++
. hello.
has trimStart? ++ yes ++
.hello .
has trimEnd? ++ yes ++
. hello.