Skip to content

reverse ​

js
_.reverse(array)

反转 array,使第一个元素成为最后一个元素,第二个元素成为倒数第二个元素,依此类推。

¥Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.

注意:此方法修改 array 并基于 Array#reverse。

¥Note: This method mutates array and is based on Array#reverse.

新增于 ​

¥Since

4.0.0

参数 ​

¥Arguments

  1. array (数组):要修改的数组。

    ¥array (Array): The array to modify.

返回 ​

¥Returns

(数组):返回 array。

¥(Array): Returns array.

示例 ​

¥Example

js
var array = [1, 2, 3];

_.reverse(array);
// => [3, 2, 1]

console.log(array);
// => [3, 2, 1]

Lodash v4.17 中文网 - 粤ICP备13048890号