Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Created January 3, 2016 20:23
Show Gist options
  • Save vlad-bezden/1a2e9ea8c7f322211a9c to your computer and use it in GitHub Desktop.
Save vlad-bezden/1a2e9ea8c7f322211a9c to your computer and use it in GitHub Desktop.
Array reverse

Array reverse

Even though reverse function exist in Array.prototype.reverse, this example shows how it can be done using reduceRight function of ES5

A Pen by Vlad Bezden on CodePen.

License.

'use strict';
let data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var result = data.reduceRight((prev, cur) => prev.concat(cur), []);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment