I'm working on some simple Javascript codes and there is something I'm not sure I understand. When I input this code,
for (var x = 0; x < 5; x++)
{
console.log(x);
}
naturally, it prints out 0 to 4. But if I add
for (var x = 0; x < 5; x++)
{
console.log(x);
}
console.log(x);
then it will print out 0 to 5. Why does it print out 5?