Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

last iteration is for loop js ES6

const array = [1, 2, 3];
for (const [i, v] of array.entries()) {
    //Handled last iteration
    if( i === array.length-1) {
        continue;
    }
    console.log(i, v)// it will print index and value
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #iteration #loop #js
ADD COMMENT
Topic
Name
4+7 =