Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to rotate an array in javascript

function arrayRotate(arr, reverse) {
  if (reverse) arr.unshift(arr.pop());
  else arr.push(arr.shift());
  return arr;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #rotate #array #javascript
ADD COMMENT
Topic
Name
6+4 =