Trim Methods
Video
JavaScript Notes
JavaScript
// trim, trimStart, trimEnd
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
// space, tab, no-break space, LF, CR
let nbsp = '\u00A0';
let cr = '\u000D';
let lf = '\u000A';
let tab = '\t';
let sentence = ` This is not the sentence you are looking for. ${nbsp} `;
let trimmed = sentence.trimEnd();
console.log('1:' + sentence + trimmed);
console.log('2:' + trimmed + sentence);
Feedback
Submit and view feedback