dimensionality
Find the number of dimensions of an array
npm install dimensionality --save
Usage
dimensionality(array[, shallowSearch = false])
Returns the maximum array depth of the array, meaning the maximum number of nests in the nested arrays.
var dimensionality = ; // 0 // 0 // 1 // 1 // 2 // 3 // 4 // shallowSearch example // 3 // 2 // 3
ShallowSearch
By default, shallowSearch = false
.
If shallowSearch = true
, then dimensionality finds the dimension only searching for the first element of the nested array.
This is useful for large data structures that are known to have equal array depth.