var a = [1, 2, 2, 2, 2, 3, 4]; for (var i = 0; i < a.length; ) { if ((a[i] % 2) == 0) { a.splice(i, 1); } else i++ } alert(a);