How to check if array is multidimensional? (jQuery)

You need to check the first element of Array so use

if(arr[0].constructor === Array)

DEMO

alert("[[]] returns " + ([[]].constructor === Array))


If you like my answer, please vote for the person above me, but here is the above answer reconstructed in function format:

function is2dArray(array){
    if(array[0] === undefined){
        return false;
    }else{
        return (array[0].constructor === Array);
    }
}

demo


You can also check all elements in the array so I think it would be more right way in 2019

const is2dArray = array =>  array.every(item => Array.isArray(item));