# prefer-array-last-methods

Rule `unicorn/prefer-array-last-methods`. Prefer last-oriented array methods over `Array#reverse()` or `Array#toReversed()` followed by a method.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #970 by reach, #1225 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/prefer-array-last-methods` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/prefer-array-last-methods.md) |

## Code examples

### Incorrect: the rule reports this

```js
const result = array.reverse().find(isUnicorn);
```

```js
const result = array.toReversed().reduce(reducer, initialValue);
```

### Correct: the rule accepts this

```js
const result = array.findLast(isUnicorn);
```

```js
const result = array.reduceRight(reducer, initialValue);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/prefer-array-last-methods": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-array-from-range](https://lintradar.dev/rules/unicorn/prefer-array-from-range.md): Prefer `Array.from({length}, …)` when creating range arrays.
- [unicorn/prefer-await](https://lintradar.dev/rules/unicorn/prefer-await.md): Prefer `await` over promise chaining.
- [unicorn/prefer-array-from-map](https://lintradar.dev/rules/unicorn/prefer-array-from-map.md): Prefer using the `Array.from()` mapping function argument.
- [unicorn/prefer-direct-iteration](https://lintradar.dev/rules/unicorn/prefer-direct-iteration.md): Prefer direct iteration over default iterator method calls.
- [unicorn/prefer-aggregate-error](https://lintradar.dev/rules/unicorn/prefer-aggregate-error.md): Prefer `AggregateError` when throwing collected errors.
- [unicorn/prefer-dom-node-replace-children](https://lintradar.dev/rules/unicorn/prefer-dom-node-replace-children.md): Prefer `.replaceChildren()` when replacing DOM children.

---

Web page: https://lintradar.dev/rules/unicorn/prefer-array-last-methods. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
