Javascript 使用.map时如何获取不可变列表中的下一个元素?

Javascript 使用.map时如何获取不可变列表中的下一个元素?,javascript,reactjs,immutable.js,Javascript,Reactjs,Immutable.js,我有一个这样的不可变列表 const list = new List([ new Map({ title: 'first', complete: true }), new Map({ title: 'second',complete: false }), ]) 当我使用 list.map((value,index) => { //HOW TO GET VALUE OF NEXT ELEMENT IN HERE ? }) 你可以这样做 list.map((value,index) =&g

我有一个这样的不可变列表

const list = new List([
new Map({ title: 'first', complete: true }),
new Map({ title: 'second',complete: false }),
])
当我使用

list.map((value,index) => {
//HOW TO GET VALUE OF NEXT ELEMENT IN HERE ?
})

你可以这样做

list.map((value,index) => {
  const next = list.get(index + 1);
  // next will be undefined when the value is last one in the list (and index + 1) is out of bounds because of that
})
为了澄清这一点,这个例子使用了一个事实,即不可变列表是Collection.Indexed的后代,它具有