DEV Community

Discussion on: How to Recognize an Array

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

There are two more,

testArray.constructor === Array  // true
testArray.constructor.name === 'Array'  // true

Also, I believe .constructor.toString() === 'function Array() { [native code] }'

But if a class extends Array, most cases become false, except Array.isArray and instanceof.

Collapse
 
bogicevic7 profile image
Dragoljub Bogićević

Thank you for the response, I have included your suggestions...