---
description: random element of an array
---

# randomElement()

{% tabs %}
{% tab title="randomElement()" %}
```javascript
// ⭐️ global: randomElement(arr)
function randomElement(arr){
    return arr[randomInt(arr.length)];
}
```
{% endtab %}

{% tab title="👥 相關" %}
* [array.random()](../../../js/val/builtin/arr/ext/random)
{% endtab %}
{% endtabs %}
