javascript loop through array backwords
var arr = [1, 2, 3, 4, 5];
for (var i = arr.length - 1; i >= 0; i--) {
console.log(arr[i]);
}
javascript loop through array backwords
var arr = [1, 2, 3, 4, 5];
for (var i = arr.length - 1; i >= 0; i--) {
console.log(arr[i]);
}
javascript reverse array
var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
.reverse javascript
const array1 = [1,2,3,4];
console.log('array1:', array1);
//"array1:" Array [1, 2, 3, 4]
const reversed = array1.reverse();
console.log('reversed:', reversed);
//"reversed:" Array [4, 3, 2, 1]
// Careful: reverse is destructive -- it changes the original array.
console.log('array1:', array1);
//"array1:" Array [4, 3, 2, 1]
how to reverse loop in javascript
const array = [6,7,8,9,10];
for (const number of array.reverse()) {
console.log(number);
}
reverse array javascript
// reverse array with recursion function
function reverseArray (arr){
if (arr.length === 0){
return []
}
return [arr.pop()].concat(reverseArray(arr))
}
console.log(reverseArray([1, 2, 3, 4, 5]))
reverse array in javascript
const reverseArray = arr => arr.reduce((acc, val) => [val, ...acc], [])
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us