DEV Community

Cover image for How to check if Variable is an Array in JavaScript

How to check if Variable is an Array in JavaScript

Samantha Ming on May 13, 2020

Here's a Code Recipe to check whether a variable or value is either an array or not. You can use the Array.isArray() method. For older browser, y...
Collapse
 
omenlog profile image
Omar E. Lopez β€’

Hi Samantha, excellent post !! I didn't know about the Array gotchas between different frames, so thanks for share it. I think in the typeof table you can include Symbol and BigInt as examples also :)

Collapse
 
samanthaming profile image
Samantha Ming β€’

Ya, that was an interesting discovery for me as well πŸ™‚ I was thinking about including Symbol and BigInt, but I thought I was introducing too much. But for completeness, that should absolutely be included πŸ˜†

Collapse
 
sergix profile image
Peyton McGinnis β€’

Wow, quite the thorough and detailed explanation. Thanks!

Collapse
 
samanthaming profile image
Samantha Ming β€’

Thanks for the positive feedback! Glad you enjoyed it 😊

Collapse
 
jamesingold profile image
James Ingold β€’

Awesome, thorough article!