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.
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.
'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); |