javascript move last array element to first
let arr1 = [1, 2, 3, 4, 5]
let arr2 = [1, 2, 3, 4 ,5]
// first to the last
arr1.push(arr1.shift()) // [2, 3, 4, 5, 1]
// last to the first
arr2.unshift(arr2.pop()) // [5, 1, 2, 3, 4]
javascript move last array element to first
let arr1 = [1, 2, 3, 4, 5]
let arr2 = [1, 2, 3, 4 ,5]
// first to the last
arr1.push(arr1.shift()) // [2, 3, 4, 5, 1]
// last to the first
arr2.unshift(arr2.pop()) // [5, 1, 2, 3, 4]
move first element to last javascript
function shiftElementToLastPlace(array){
let arr = [...array]
arr.push(arr.shift())
return arr
}
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