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

unshift

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

Returns a new sequence with the same elements as this one, plus the specified element at the beginning.

Signature

ArrayLikeSequence.unshift = function() { /*...*/ }
ArrayLikeSequence.unshift = function unshift(value) {
  return Lazy([value]).concat(this);
}
NameType(s)Description
returnsArrayLikeSequence

The new array-like sequence.

Examples

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