通常,在某些情况下我需要确定Javascript数组是否为矩形(并获取数组的尺寸).在这种情况下,我的意思是确定数组的每个元素是否是具有相同长度的数组.我怎样才能做到这一点?
function getArrayDimensions(theArray){
//if the array's dimensions are 3x3, return [3, 3], and do the same for arrays of any dimension
//if the array is not rectangular, return false
}
Run Code Online (Sandbox Code Playgroud)
另外,如何将此函数推广到多维数组(2x5x7,3x7x8x8等)?