Skip to content

Instantly share code, notes, and snippets.

@DanielHemmati
Created August 22, 2019 19:37
Show Gist options
  • Save DanielHemmati/3aaa48e36c6775a43df4ca65f6ed7af0 to your computer and use it in GitHub Desktop.
Save DanielHemmati/3aaa48e36c6775a43df4ca65f6ed7af0 to your computer and use it in GitHub Desktop.
reverse array with pop
/**
* @param {array} array
*/
function reverse(array) {
var res = [];
for (var i = array.length-1 ; i >= 0; i--) {
res.push(array.pop());
}
return res;
}
console.log(reverse([1,2,3]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment