var mass = []; mass[4] = 4 mass[9] = "9a9" mass[8] = 9 console.log(mass.join().split(/\d+/).length - 1); //>>>> 4