# str.reverse()

{% tabs %}
{% tab title="💾 程式" %}
```javascript
// reverseString()
export function reverseString(str) {
    return str.split("").reverse().join("");
}

// str.reverse()
String.prototype.reverse = function(){
    return reverseString(this);
}
```
{% endtab %}

{% tab title="📗 參考" %}
* [x] freeCodeCamp ⟩ [Three Ways to Reverse a String in JavaScript](https://www.freecodecamp.org/news/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb/)\
  1\. array.reverse()    2. for-loop   3. recursion
{% endtab %}

{% tab title="📘 手冊" %}
* [array.reverse()](https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) - reverse **in place**. ⭐️
{% endtab %}

{% tab title="👥 相關" %}
* [arr.reversed](../../../builtin/arr/ext/arr.reversed "mention")
{% endtab %}
{% endtabs %}
