i wants to separate an array with two groups (odd and even) sequentially. but when i try this:
The way you do it is so complicated. You can simply achieve that with array.prototype.filter and array.prototype.concat:
array.prototype.filter
array.prototype.concat
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr = arr.filter(e => e%2).concat(arr.filter(e => e%2 === 0)); console.log(arr);