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

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);
}
NameType(s)Description
countnumber?

The number of items to omit from the end of the sequence (defaults to 1).

returnsSequence

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]