Often, there are situations where I need to determine whether a Javascript array is rectangular (and get the dimensions of the array). In this case, I mean determining whether every element of the array is an array with the same length. How can I do this?
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
}
Additionally, how can this function be generalized to multidimensional arrays (2x5x7, 3x7x8x8, etc.)?