var arr = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12];
var arr1 = [] //make a separate array to store numbers fulfilling specified condition
$.each(arr,function(i,v){
if(somethingIsTrue){
arr1.push(v) //fill second array with required numbers fulfilling specified condition
}
});
Working Demo
OR
var arr = [1,2,2,2,3,4,5,5,5,6,7,8];
var filteredarr = $.map(arr,function (value,index) {
return (somethingIsTrue ? value : null)
});
'filteredarr' will be a another array having numbers satisfying the condition.
Working Demo
OR
Try .splice() as shown :
var arr = [1,2,3,4,5];
$(arr).each(function(index, value){
if(somethingIsTrue){
arr.splice(index,1)
}
});
Working Demo
OR
$.each(arr,function(i,v){
if(somethingIsTrue){
var i1 = arr.indexOf(v);
arr.splice(i1,1);
}
});
Working Demo
NOTE :- Last two answers will work absolutely fine if array do not contains repeating numbers(as questioner specified in question) and first two answers will work in any scenario.
poponly removes the last element in the array.