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

size

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

Gets the number of elements in the sequence. In some cases, this may require eagerly evaluating the sequence.

Signature

Sequence.size = function() { /*...*/ }
Sequence.size = function size() {
  return this.getIndex().length();
}
NameType(s)Description
returnsnumber

The number of elements in the sequence.

Examples

Lazy([1, 2, 3]).size();                 // => 3
Lazy([1, 2]).map(Lazy.identity).size(); // => 2
Lazy([1, 2, 3]).reject(isEven).size();  // => 2
Lazy([1, 2, 3]).take(1).size();         // => 1
Lazy({ foo: 1, bar: 2 }).size();        // => 2
Lazy('hello').size();                   // => 5