Easy way to revert a form var to its default value?

Is there a easy way to revert a form variable back to its default value? I currently do the following, but it seems a little excessive and hackish using an eval()…

var frm_tracking_number = null;

if (some_condition_im_testing_for == false) {
    var myForm = solutionModel.getForm(currentcontroller.getName());
    var fvariable_frm_tracking_number = myForm.getFormVariable("frm_tracking_number");
    currentcontroller.setDataProviderValue(fvariable_frm_tracking_number.name, eval(fvariable_frm_tracking_number.defaultValue));
}

The eval() is needed because .defaultValue will return a string and thats no good for cases where the default value is something more complex than a number or string, like null in this case.

P.S. Yes, I am fully aware I could just do frm_tracking_number = null in my if() block, but it has much less load on my brain to only have to keep track of one spot (where the var is defined) for each form variable’s default value if I need to change it.

that is a way to do it yes, another way is to somehow store all the values of a form in an special array, you can fill this array on the form in the onload of the form

Per Johan’s suggestion, we create a form variable of media type called “_defaults” with value of {}. Then run this code in the onLoad event:

var vars = ( allvariables ) ? allvariables : 0
for (var i = 0; i < vars.length; i++) {
	if ( vars[i] != "_defaults" ) {
		_defaults[vars[0]] = forms[controller.getName()][vars[0]]		                       
	}
}

Makes it easy to reference default values with:

_defaults["_formVarName"]