Check if type of value is an Array
Problem
You want to check if a value is an Array
.
The typeof
operator gives a faulty output for arrays.
Solution
Use the following code:
To use this, just call typeIsArray
as such:
Discussion
The method above has been adopted from “the Miller Device”. An alternative is to use Douglas Crockford’s snippet: