Skip to content

Trim white spaces at the beginning of the string in JavaScript

To trim white spaces at the beginning of a string we can use trimStart() method. This method returns a new string with whitespaces removed and it do not alter the original value of a string. trimLeft() is the alias of this method.

Advertisements
var str = "   poopcode";

console.log(str.trimStart());
//poopcode
console.log(str.trimLeft());
//poopcode
See also  Maximum Product Subarray - Leetcode Challenge - Python Solution
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.