# random-item

> Get a random item from an array

Latest version **4.0.1** (published 2021-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install random-item
pnpm add random-item
yarn add random-item
bun add random-item
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2021-05-24 |
| First published | 2015-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/random-item) |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 58 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | random, randomize, math, array, item, element, pick, select |

## Links

- npm: https://www.npmjs.com/package/random-item
- Repository: https://github.com/sindresorhus/random-item
- Homepage: https://github.com/sindresorhus/random-item#readme
- Issues: https://github.com/sindresorhus/random-item/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/random-item

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2021-05-24
- 4.0.0 — 2021-04-16
- 3.1.0 — 2020-10-28
- 3.0.0 — 2019-04-17
- 2.0.0 — 2019-04-11
- 1.0.0 — 2015-06-26

## README

# random-item

> Get a random item from an array

## Install

```
$ npm install random-item
```

## Usage

```js
import randomItem from 'random-item';

randomItem(['🐴', '🦄', '🌈']);
//=> '🦄'

randomItem.multiple(['🐴', '🦄', '🌈'], 2);
//=> ['🌈', '🦄']
```

## Related

- [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer
- [random-float](https://github.com/sindresorhus/random-float) - Generate a random float
- [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
- [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
- [unique-random-array](https://github.com/sindresorhus/unique-random-array) - Get consecutively unique elements from an array
- [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string

---
_Source: https://npm.io/package/random-item · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
