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

get

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

Returns the element at the specified index.

Signature

ArrayLikeSequence.get = function(i) { /*...*/ }
ArrayLikeSequence.get = function get(i) {
  return this.parent.get(i);
}
NameType(s)Description
inumber

The index to access.

returns*

The element.

Examples

function increment(x) { return x + 1; }

Lazy([1, 2, 3]).get(1)                // => 2
Lazy([1, 2, 3]).get(-1)               // => undefined
Lazy([1, 2, 3]).map(increment).get(1) // => 3