javascript - Get iteration count of for...of loop -


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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -