“JS Detecte o final da matriz” Respostas de código

JS Detecte o final da matriz

var group = ["a","b","c","d"];
var groupLength = group.length;

while (groupLength--) {
    var item = group[groupLength];

    if(groupLength == 0){
        console.log("Last iteration with item : " + item);
    }
}
Modern Mouse

JS Detecte o final da matriz

var group = ["a","b","c","d"];
var groupLength = group.length;

for(var i = 0;i < groupLength;i++){
    var item = group[i];

    // Do something if is the last iteration of the array
    if((i + 1) == (groupLength)){
        console.log("Last iteration with item : " + item);
    }
}
Modern Mouse

Respostas semelhantes a “JS Detecte o final da matriz”

Perguntas semelhantes a “JS Detecte o final da matriz”

Mais respostas relacionadas para “JS Detecte o final da matriz” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código