What resets global variables to "undefined"

I am trying to understand what causes global variables to be reset. I feel like most times I hit deploy it does not reset them, but sometimes when I deploy all get set to undefined.

The background to this questions is I had some kind of power surge last night and the monitor connected to my Pi turned off, among other things. All of my global variables had been reset to undefined, but node red did not deploy and was still running fine.

It will depend on what kind of deploy you do
and how you have setup the context store
https://nodered.org/docs/user-guide/context

Thank you for the reply. My context store is default, and I always use full deploy. Other threads show that any kind of deploy is not supposed to reset the global variables, are you saying thats not the case?

If deploy does not reset them, is the only way to restart node red entirely?