Your g
variable is within the global context, so it is accessible outside of a for
loop.
The loop did its job, and incremented g
10 times.
Two {}
indicate a block in JavaScript and won't cause any error.
Edit: it is not alerting anything without a for
loop, because the g
variable is not defined.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…