# Multidimensional Array Length

Hi.

Is there any function or property for finding out the size of the first (or for that matter any) dimension of a multidimensional array?

EDIT:

There seems to be no such functionality, I found a solution that does not require it. If anyone is reading this for the same reason; it needs to be scripted.

If I understand

``````
<script type="text/javascript">

var A = [

["The Time Through Ages","In the Name of Allah, Most Gracious, Most Merciful,","1. By the Time,","2. Verily Man is in loss,"," 3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy."],

["The Opening", "1. In the name of Allah, Most Gracious, Most Merciful.", "2. Praise be to Allah, the Cherisher and Sustainer of the worlds;", "3. Most Gracious, Most Merciful;", "4. Master of the Day of Judgment.", "5. Thee do we worship, and Thine aid we seek.", "6. Show us the straight way,", "7. The way of those on whom Thou hast bestowed Thy Grace, those whose (portion) is not wrath, and who go not astray."]

]

alert (A[0][0]);        // The Time Through Ages

var s = "";
var t = "<table border=2 ><tbody>";

for(var i=0; i< A.length; i++) {

t +="<tr><td>" + A[i].length + "</td>";

var sum = 0;

for(var k= 0; k < A[i].length; k++){

sum += A[i][k].length;

t += "<td>" + A[i][k] + "-----" + A[i][k].length + "</td>";

}

t += " <td>" +sum+"</td></tr>";

}

t+= "</tbody></table>";

document.write(t);

</script>

``````

Since JavaScript doesn’t have multi-dimensional arrays there is no such thing as multi-dimensional array length in JavaScript.

Each element in a JavaScript array can itself be an array giving the equivalent of a multi-dimensional array but the lengths of the arrays iyou add for the second dimension are not forced to be the same and so while you have one length for the first dimentsion of the array each of those elements has its own separate length for the second dimension and so on for as many more arrays within arrays as you build.