5.3.3 String
6.trim() 方法
ECMAScript在所有字符串上都提供了 trim() 方法。這個方法會創建
字符串的一個副本,刪除前、后所有空格符,再返回結果。比如:
let stringValue = " hello world "; let trimmedStringValue = stringValue.trim(); console.log(stringValue); // " hello world " console.log(trimmedStringValue); // "hello world"
另外, trimeLeft() 和 trimRight() 方法分別用於從字符串開始
和末尾清理空格符。