Let\'s say I have
myArray = [\'item1\', \'item2\']
I tried
for (var item in myArray) {console.log(item)}
It
Use Iterators...
var myarray = ['hello', ' hello again'];
processArray(myarray[Symbol.iterator](), () => {
console.log('all done')
})
function processArray(iter, cb) {
var curr = iter.next()
if(curr.done)
return cb()
console.log(curr.value)
processArray(iter, cb)
}
More in depth overview: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols