> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/prim/str/method/str.removewhitespaces.md).

# str.removeWhitespaces()

{% tabs %}
{% tab title="💾 程式" %}

```javascript
// 🔸 str.removeWhitespaces()
String.prototype.removeWhitespaces = function() {
    return this.replace(/\s+/g, '');
};
```

💈範例：

```javascript
// multi-line string
let str = `
as     void     async     while
`;

str.removeWhitespaces()    // "asvoidasyncwhile"
```

{% endtab %}

{% tab title="👥 相關" %}

* [str.replaceWhitespaces()](/web/js/val/prim/str/method/str.replacewhitespaces.md) - replace white-spaces with specific delimiter.
  {% endtab %}

{% tab title="⬇️ 應用" %}

* [不能補考名單](/web/appendix/gas/projects/no-make-up-exam.md)
* [各班平均及前三名](/web/appendix/gas/projects/class-average.md)
  {% endtab %}
  {% endtabs %}
