---
title: "unicorn/no-instanceof-array"
description: "Require `Array.isArray()` instead of `instanceof Array`"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "unicorn"
aliases: []
kind: "suggestion"
category: "pedantic"
default: "off"
fixable: "yes"
typeAware: false
deprecated: false
---

Every iframe and every `node:vm` context has its own `Array`. An array created in another one isn't an instance of yours, so `instanceof Array` is `false` for it. `Array.isArray()` is `true` for every array.

`--fix` rewrites `value instanceof Array` to `Array.isArray(value)`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/no-instanceof-array" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
function toList(value) {
  return value instanceof Array ? value : [value];
}
```

Not reported:

{/* good */}
```js
function toList(value) {
  return Array.isArray(value) ? value : [value];
}
```
