How would I test to see if a variable includes an multidimensional array? For example:
var obj = [1, 2];
vs
var obj = [[1], [2]];
I have used Array.isArray(obj) to test whether is an array, but I can't figure out how to test the number of arrays.
Assuming you meant
var ratings = [[1], [2]];
as var ratings = [1], [2]; is a syntax error, you could do
ratings.filter(Array.isArray).length
to get the number of arrays inside the wrapping array (2)
FIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With