Array.prototype.map
calls it a callback with parameters 3 :
currentValue
index
array
This means that of course you can access the array through its index as part of the callback procedure. For example:
contents.map((content, index, array) => {
switch(content.type) {
case 1:
console.log("type is one and next type is: ", array[index+1] ? array[index+1].type : 'empty');
break;
case 2:
console.log("type is two")
break;
}
});
: https://jsfiddle.net/z1sztd58/
: MDN