Javascript String trimStart()

Introduction

The trimStart() method removes whitespace from the beginning of a string.

trimLeft() is an alias of this method.

str.trimStart();

The following example displays the lowercase string 'foo ':

var str = '   foo  ';

console.log(str.length); // 8

str = str.trimStart();
console.log(str.length); // 5
console.log(str);        // 'foo  '



PreviousNext

Related