revision:
The trimStart() method removes whitespace from the beginning of a string. It does not change the original string.
This method works like trim(), but removes whitespace only from the start of a string.
string.trimStart()
Parameters: none
<p>trimStart() removes whitespace from the start of a string:</p> <pre><;p id="demo"></p></pre> <script> let text1 = " Hello World! "; let text2 = text1.trimStart(); document.getElementById("demo1").innerHTML = "Length text1 = " + text1.length + "<br>Length text2 = " + text2.length; </script>
<div> <p id="trim-1"></p> <p id="trim-2"></p> <p id="trim-3"></p> </div> <script> let text1 = " Hello World! "; document.getElementById("trim-1").innerHTML = "untrimmed text : " + text1; let text2 = text1.trimStart(); document.getElementById("trim-2").innerHTML = "Length text1 = " + text1.length + "<br> Length text2 = " + text2.length;; </script>