count in array by gaby de wilde January 07, 2016 JavaScript my_array = [1, 2, 3, 5, 2, 8, 9, 2]; alert(eval('('+my_array.join('==2)+(')+'==2)'))