javascript - Get iteration count of for...of loop -
this question has answer here:
how current iteration count of for...of loop?
let iterable = new set([1, 1, 2, 2, 3, 3]); let = 0; (let value of iterable) { console.log('value in iteration count = ' + + ' :' + value); i++; } this have, there kind of built in iteration count variable can replace variable i?
you can use indexof if don't want make temp variable, solution more efficient. can iterate on keys of collection, rather values.
Comments
Post a Comment