GitHub Package
the javascript
07 - Mutated Function Parameters

Objects and Arrays can be guarded from mutations in function calls with check_buildSnapshot() recording the entry value, and check_mutatedSnapshot() giving errors when referential variables get unwanted changes.

Checking for variable mutation is accomplished by first creating a snapshot copy of the object or array in the PRE checking function with check_buildSnapshot(). In the example to the left, the function name of 'PRE_check_Person' is recorded, along with the variable name of 'a_person', followed finally with the current variable value.

The POST checking function then verifies that no changes have occured in the varaible via check_mutatedSnapshot(). The orginating function and variable name are needed to locate the specific object or array that is being checked.

It can be somewhat disconcerting to view the error messages as object keys are sorted for easy comparing.

Console Output