_.reverse
Lodash only
Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
- // Lodash
- var array = [1, 2, 3]
- console.log(_.reverse(array))
- // output: [3, 2, 1]
- // Native
- var array = [1, 2, 3]
- console.log(array.reverse())
- // output: [3, 2, 1]
Voice from the Lodash author:
Lodash's
.reverse
just callsArray#reverse
and enables composition like.map(arrays, .reverse).
It's exposed on because previously, likeUnderscore
, it was only exposed in the chaining syntax.—- jdalton
Browser Support for Array.prototype.reverse()
✔ | ✔ | 1.5 ✔ | 9 ✔ | ✔ | ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .