I would like to store the initial state of the "this" (global) scope as shown in the pseudo code below :
<script>
var copiedObject = Object.create(this);
x="foo";
console.log(x); // foo
</script>
and reset it to this state later on using :
<script>
this = Object.create(copiedObject);
console.log(x); // undefined since it's a copy before x was assigned
</script>
Is this the correct way of cloning this and using that clone to replace the original later on ? I would like to do this instead of "refreshing" the page of my HTML5/JavaScript app and purge newly added functions from AJAX.