showing results for - "how to get the next item in map 28 29 js"
Jayden
05 Nov 2016
1// The callback of map method accepts 3 arguments:
2
3// current item value;
4// current item index;
5// the array map was called upon.
6// So, you could use index to get next element value:
7
8var newArray  = myArray.map(function(value, index, elements) {
9  var next = elements[index+1];
10  // do something
11});