_.reverse

❗️Lodash onlyReverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

  1. // Lodash
  2. var array = [1, 2, 3]
  3. console.log(_.reverse(array))
  4. // output: [3, 2, 1]
  5.  
  6. // Native
  7. var array = [1, 2, 3]
  8. console.log(array.reverse())
  9. // output: [3, 2, 1]

Voice from the Lodash author:

Lodash's .reverse just calls Array#reverse and enables composition like .map(arrays, .reverse).It's exposed on because previously, like Underscore, it was only exposed in the chaining syntax.—- jdalton

Browser Support for Array.prototype.reverse()

ChromeEdgeFirefoxIEOperaSafari
1.5 ✔9 ✔