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

BY Best Interview Question ON 20 Jun 2020

Example

var count = 0;

for(var i = 0; i

if(array[i] == 2)

count++;

}