The Setup var default = { param1: "one", param2: "two", param3: [] }, working = default; // Fill form fields from working data // User modifies form fields // Save form fields in working data // Perform calculation based on working data // User clicks a button to reset the form to default state function reset(){ working = default; // Fill form fields from working data // Perform calculation based on working data } The Problem The form was not being reset to the default data, but instead did not change at all. When I debugged, I noticed that the data in default was identical to the data in working , even though I never assign any values to default after initialization. The Cause Little did I know, that assigning an object in JavaScript actually only assigns the reference, and does not create a new copy of the object. The Solution The object needs to be copied, rather than simply assigned. Based on a quick Google search, there is no bui...
Lessons learned and interesting tidbits from my adventures in web development