js堅持不懈之18:trim()方法

trim()方法,相似Python中的strip(),用去去除字符串對象先後的空格。html

<!DOCTYPE html>

<html>

<body>
<script>
var s = "       afsdf           ";
document.write("|" + s + "|" + "<br>");
var s2 = s.trim();
document.write("|" + s2 + "|" + "<br>");
</script>
</body>
</html>

相關文章
相關標籤/搜索