Loading…

How to count the number of element in an array using Javascript?

To count the number of elements in an array using JavaScript, use the following

Example

                                        

var count = 0;

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

if(array[i] == 2)

count++;

}

Suggest An Answer

No suggestions avaliable!

Latest post from JavaScript interview questions

Ask Question