Package to replace
is-arrayish
Suggested replacement(s)
Array.isArray() (native)
Manifest type
micro-utility (tiny utility replaceable with native code or removal)
Rationale
is-arrayish checks if an object can be used like an Array either a true array or an object with an Array prototype in its chain ({__proto__: []}). Both cases are fully covered by native JavaScript:
Array.isArray() handles direct arrays and cross-realm arrays (e.g. from vm contexts or iframes)
obj instanceof Array covers the prototype-chain case ({__proto__: []}) for same-realm objects
Availability
Built-in since ES5 / Node.js 0.1.101. No install required.
Code example (optional)
// Before
const isArrayish = require('is-arrayish')
isArrayish([]) // true
isArrayish({ __proto__: [] }) // true
isArrayish({}) // false
// After — sufficient for most cases
Array.isArray([]) // true
Array.isArray({ __proto__: [] }) // false — see note above
Array.isArray({}) // false
// After — exact drop-in replacement if prototype-chain behaviour is needed
function isArrayish(obj) {
if (obj == null) return false
return Array.isArray(obj) || obj instanceof Array
}
Package to replace
is-arrayishSuggested replacement(s)
Array.isArray()(native)Manifest type
micro-utility (tiny utility replaceable with native code or removal)
Rationale
is-arrayishchecks if an object can be used like an Array either a true array or an object with an Array prototype in its chain ({__proto__: []}). Both cases are fully covered by native JavaScript:Array.isArray()handles direct arrays and cross-realm arrays (e.g. fromvmcontexts or iframes)obj instanceof Arraycovers the prototype-chain case ({__proto__: []}) for same-realm objectsAvailability
Built-in since ES5 / Node.js 0.1.101. No install required.
Code example (optional)