str.trim()
<html>
<body>
<script>
function func_trim() {
var str = " lidihuo tutorial website ";
var trimmedstr = str.trim();
document.write(trimmedstr);
}
func_trim();
</script>
</html>
</body>
<html>
<body>
<script>
function func_trim() {
var str = "lidihuo tutorial website ";
var trimmedstr = str.trim();
document.write(trimmedstr);
}
func_trim();
</script>
</html>
</body>
<html>
<body>
<script>
function func_trim() {
//original string with whitespace in beginning
var str = " lidihuo tutorial website";
//string trimmed using trim()
var trimmedstr = str.trim();
document.write(trimmedstr);
}
func_trim();
</script>
</html>
</body>
trimLeft()
trimRight()
str.trimLeft()
<html>
<body>
<script>
function func_trim() {
var str = " lidihuo tutorial website ";
var trimmedstr = str.trimLeft();
document.write(trimmedstr);
}
func_trim();
</script>
</html>
</body>
str.trimRight()
<html>
<body>
<script>
function func_trim() {
//original string with whitespace from the end
var str = " lidihuo tutorial website ";
//string trimmed using trimRight()
var trimmedstr = str.trimRight();
document.write(trimmedstr);
}
func_trim();
</script>
</html>
</body>