What is the most efficient and/or most readable way to write a function that takes in an array and returns the degree of multi-dimensionality of that array. For now it can be assumed that the arrays only contain primitive types.
Example.
var arr = [[1,2],[3,4],[5,6]]
function findDim(a){
//logic goes here
}
findDim(arr); // returns 2
[ 1, [2,3], [[4]] ]?