óCoffeeScript Cookbook

转置数组 Reversing Arrays

问题 Problem

你想转置一个数组。

You want to reverse an array.

方法 Solution

使用JavaScript中数组的reverse()方法:

Use JavaScript’s Array reverse() method:

["one", "two", "three"].reverse()
# => ["three", "two", "one"]

详解 Discussion

reverse()是一个标准的JavaScript方法。可别把括号望打了。

reverse() is a standard JavaScript method. Don’t forget the parentheses.