0
var arr = [];

for (var i = 0; i < 5; i++) {
  arr[i] = function () {
    return i;
  };
}

for (var j = 0; j < arr.length; j++) {
  console.log(arr[j]());
}

[console] 5(5)

I'm curious about the log above the code I think when the bottom loop run, the log should show 4(5). But I don't realize where Number 5 come from..

김현송
  • 1
  • 1

0 Answers0