Usage of loops for defining new variables

I read through the documentation and the other topics, i.e.

https://stackoverflow.com/questions/51930537/scope-of-variables-in-julia/

and the link provided by @rdeits.

Yes, I also did feel it is counter intuitive, simply because I have never thought a for/while loop the same as a function, i.e .to have its own variable space. In other words, I simply did not expect
x(1) = 1
x (2) = 2
and
for i = 1:2
x[i] = i;
end
to have different behaviour, I simply saw the for loop as an easier way not to have to write the same thing many times. Technically this is the way a function works, so it makes sense once I think about it, it was a point I have never thought about.

However, neither the documentation, nor the links provide an answer to my question regarding speed and global variables - is declaring a variable as global in a loop “bad” in terms of leading to performance loss? I mean in terms of the typical arguments against global variables (in relation to variable type and machine code optimization), e.g. here or here. It is noted in the manual, that changing the values of global variables is not recommended but then, isn’t changing the value of a variable iteratively the main purpose of loops?

If it does, than this speaks for avoiding loops or am I missing something? I do a lot of Markov Chain Monte Carlo in my work where loops are essential. Every step of my program depends typically on the previous iteration and within a loop I change most of the variables of interest, i.e. they all have to be global.