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

shuffle

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

Creates a new sequence with the same elements as this one, in a randomized order.

Signature

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

The new sequence.

Examples

Lazy([1, 2, 3, 4, 5]).shuffle().value() // =~ [1, 2, 3, 4, 5]
Lazy([]).shuffle().value()              // => []
Lazy([1]).shuffle().each(Lazy.noop)     // => true
Lazy([]).shuffle().each(Lazy.noop)      // => true