Skip to content

Require Array.isArray() instead of instanceof Array ​

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

The instanceof Array check doesn't work across realms/contexts, for example, frames/windows in browsers or the vm module in Node.js.

Fail ​

js
array instanceof Array;
[1,2,3] instanceof Array;

Pass ​

js
Array.isArray(array);
Array.isArray([1,2,3]);

Released under the Apache License 2.0.