当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

reverse

优质
小牛编辑
136浏览
2023-12-01

Creates a new sequence with the same elements as this one, but to be iterated in the opposite order.

Note that in some (but not all) cases, the only way to create such a sequence may require iterating the entire underlying source when each is called.

Signature

Sequence.reverse = function() { /*...*/ }
Sequence.reverse = function reverse() {
  return new ReversedSequence(this);
}
NameType(s)Description
returnsSequence

The new sequence.

Examples

Lazy([1, 2, 3]).reverse() // sequence: [3, 2, 1]
Lazy([]).reverse()        // sequence: []