Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on JavaScript Interview Question. Parent comment
Your confusion is because of a javascript quirk
for (...) { var foo = bar }
var foo for (...) { foo = bar }
What you need is:
for (...) { (function(bar) { var foo = bar })(bar) }
There are no comments on this comment yet.
Your confusion is because of a javascript quirk
is actually the same as Notice how you only ever have one fooWhat you need is:
which create a new foo every time you loop