Short answer, you can't.
The reason for this is your code only executes in tiny spurts once per tick, between ticks you could lose the global memory and it would have to be recreated.
Store data you need to be persistent in the Memory object, "Memory" that's part of your global memory set up for you at the beginning of each tick. Game structures have a shortcut to the memory object that is handy for storing the data pertinent to that game structure. For example, the Creep object has a property, "memory" that points to the place in the memory object associated with that creep, keyed off it's name. So the Memory object for creep "myCreep" would be "Memory.creeps.myCreep" and can be accessed through the creep as "creep.memory"
Data that you can just recreate can be stored in global memory, but know that it could simply "go away" and you will have to rebuild it.