相关疑难解决方法(0)

如何获取多维Javascript数组的维度?

通常,在某些情况下我需要确定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等)?

javascript arrays

4
推荐指数
1
解决办法
5101
查看次数

标签 统计

arrays ×1

javascript ×1