Original Post
i'm having a problem with a global javascript variable (myStringList). initially the variable is undefined, but later i populate it with a list of strings using .split(). i use myStringList through a few functions with no problems until it backs out of the functions. here's the problem and it's quite odd. using the code below: alert("list contains : " + myStringList); alert("list contains : " + myStringList); i come out with two different outputs even though the lines of code are exactly the same and executed one after the other. when the first line is executed, the output is that of what myStringList is originally initialised with at the top of the script. after the second line is executed, it outputs the strings i had populated it with, and remains consistent after that point. for example: var myStringList = "NONE SHALL PASS!"; // global variable window.onload = function() { getStatus(); // myStringList will be populated here // with "hp,90,100,10,3,mp,50,75,15,4,ap,15,100,25,2" // using a .split() alert("list contains : " + myStringList); alert("list contains : " + myStringList); } the first alert box will say "list contains : NONE SHALL PASS!" and the second alert box will say "list contains : hp,90,100,10,3,mp,50,75,15,4,ap,15,100,25,2" and remains constant thereafter as it should have been anyways. does anyone have an idea why it is behaving in this manner?