For example in this code:
... snip
breadthFirst (callback) {
// let node; // here?
while (this.queue.length > 0) {
// let node = this.queue.shift(); // or here?
callback(node);
node.childNodes.forEach( (node) => {
this.queue.push(node);
});
}
}
}
... snip
I could have declared let just outside the while loop or inside the while loop. I'm not sure which is better.
Note that I am using let which has block scope so this previous SO question is not relevant.