Blogroll

Powered by Blogger.

Thursday 12 June 2014

Get the Number of Rows and Columns of Single and Multidimensional JavaScript Arrays

by realfinetime  |  in JavaScript 2D Array at  21:34

To get the number of elements in a single dimensional array.

var single_dim_array_with_contents = [  'control' ,'alt'    ,'delete'  ];  

To get the number of elements in this array  :  single_dim_array_with_contents.length ;
This function will return 3 from this array.

To get the number of rows and columns in a two dimensional array.

var multi_dim_array_with_contents = [

 [  'mango'   , 'orange'  , 'banana'  ],
 [  'ford'    ,   'audi'   ,  'benz'    ],
 [  'control' ,  'alt'    ,  'delete'  ]

  ]; 

To get the number of rows  :  multi_dim_array_with_contents.length;
This function will return number 3 which is the number of rows.

To get the number of columns in each rows  :   multi_dim_array_with_contents[i].length ;
' i ' stands for the row number.

0 comments:

IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.

For More Electronic Tips



Proudly Powered by Blogger.