function reverse(array) { var j = array.length - 1; for (var i = 0; i < j; i++, j--) { [array[i], array[j]] = [array[j], array[i]]; } return array; }