Using a let in a for loop with setTimeout function

If the arguments to functions are passed by value in javascript how come the console.log() below seems to get its input by reference? Shouldn’t each time it is invoked inside setTimeout just the value of i be passed and not its reference?

let i;

for (i = 1; i <= 5; i++) {
  setTimeout(function timer() {
    console.log(i);
  }, i * 1000);
}