initial
优质
小牛编辑
137浏览
2023-12-01
Creates a new sequence comprising all but the last N elements of this sequence.
Signature
Sequence.initial = function(count) { /*...*/ }
Sequence.initial = function initial(count) { return new InitialSequence(this, count); }
Name | Type(s) | Description |
---|---|---|
count | number? | The number of items to omit from the end of the sequence (defaults to 1). |
returns | Sequence | The new sequence. |
Examples
Lazy([1, 2, 3, 4]).initial() // sequence: [1, 2, 3] Lazy([1, 2, 3, 4]).initial(2) // sequence: [1, 2] Lazy([1, 2, 3]).filter(Lazy.identity).initial() // sequence: [1, 2]