If you don’t need a variable outside of a while loop, should you still declare it there? Is more memory allocated every time the loop is run otherwise?
(I figured it would be easy to google information on this, but I’m apparently not very good at it.)
welll if you declare it everytime you are running the while loop like so then yes it will use more memory but the variable will (go away)* after the part of the loop.
you will only gain memory for the one variable while the while loop is running.
var blah = 0;
while(blah < 5)
{
var blah2 = 0;
blah++;
}