I'm trying compare an value with the next value in the array, but when the loop is finished, the code that is after is not executed.
var json = [{'id':1},{'id':2},{'id':3},{'id':4},{'id':4},{'id':5},{'id':5}];
for(var i = 0; i < json.length; i++){
if(json[i].id == json[i+1].id){
console.log("Equal");
}
}
console.log('Something'); //This code is not executed
I realized that the problem is this part [i+1]. When I remove the number 1, the code is executed normally.
Does anyone know why this happens?