var arr = [1,2,3,4,5,6,7]; for(var i = 0; i < arr.length; i++){ if ( arr[i] > 4) { arr.splice(i, 1); i--; } } console.log(arr);
var arr = [1,2,3,4,5,6,7]; arr = arr.filter(function(item) { return !(item > 4); //item <= 4 }); console.log(arr);