OneCompiler

[JavaScript] How to check if the variable is an array?

How to check if a given variable is an array in Javascript?

1 Answer

4 years ago by

There are couple of ways to check if the variable is an array in Javascript

Method:1

Array.isArray(variableName)

Method:2

variableName.constructor === Array
4 years ago by Meera