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); }
Name | Type(s) | Description |
---|---|---|
returns | ArrayLikeSequence | The new array-like sequence. |
Examples
Lazy([1, 2]).unshift(3) // sequence: [3, 1, 2] Lazy([]).unshift(1) // sequence: [1]