String.prototype.trim()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015 .
trim()
方法會移除字串起始及結尾處的空白字元。
本文中的空白字元指所有空格字元(如:空格、欄標、無間斷空格等等)及換行字元(如:換行、回車等等)。