function reversInPlaceWhile(arr) {
var len = arr.length - 1;
var i = 0, temp;
while (i < len - i) {
temp = arr[i];
arr[i] = arr[len - i];
arr[len - i] = temp;
i++;
}
return arr;
}
function testA(arr) {
var start = Date.now();
for (var i = 0; i < 1000000; i++) {
reversInPlaceWhile(arr);
}
var end = Date.now();
return end - start;
function testB(arr) {
var start = Date.now();
for (var i = 0; i < 1000000; i++) {
arr.recerce();
}
var end = Date.now();
return end - start;
}
var len = arr.length - 1;
var temp;
for (var i = 0, iter = Math.floor(len / 2); i < iter; i++) {
temp = arr[i];
arr[i] = arr[len - i];
arr[len - i] = temp;
}
return arr;
function reversInPlaceWhile(arr) {
var len = arr.length - 1;
var i = 0, temp;
while (i < len - i) {
temp = arr[i];
arr[i] = arr[len - i];
arr[len - i] = temp;
i++;
}
return arr;
}
function noNative(arr) {
return reversInPlaceWhile(arr);
}