There're 2 ways to keep things in memory.
First a persistence one. You store what ever you want in Memory object as Heilos said. But it also has some useful alias with many game object such as creep and room. For example if you want to keep something only available to each room, you can use
Game.rooms['E10N10'].memory.something = 'some value';
When you spawn in new room your room data is new to that room. Same as creeps, you can store information or order for each creep you spawn by store it in Game.creeps['CreepName'].memory.order = 'attack-x,y'.
These information store in Memory object are available through game loops.
The other way to use memory is a none persistence one. Javascript allow you to add data to objects. For example
Game.rooms['E10N10'].hostiles = Game.rooms['E10N10'].find(FIND_HOSTILE_CREEPS);
Then you can use Game.rooms['E10N10'].hostiles in current game loop. This data exists only current game loop but it maybe useful to store some temporary or update-every-tick data. It save your CPU usage without call this function for every creep in that room.
.