var mass = []; mass[4] = 4 mass[9] = 9 mass[8] = 9 alert(mass.join().split(/\d+/).length - 1);
mass.join().replace(/\,{2,}/g, ',').replace(/^\,|\,$/,'').split(',').length