Can an instance of a class replace itself in JavaScript?
<p>I have a variable in a global scope which is assigned an instance of a class like this:</p>

<pre><code>window.someInstance = new MyClass();
</code></pre>

<p>At some point later, I need to replace that variable with a new instance, but is it possible/acceptable to do that from within a method of the class itself? For example:</p>

<pre><code>function MyClass () {

    this.myClassMethod = function () {
        window.someInstance = new MyClass();
    };

}

window.someInstance = new MyClass();
window.someInstance.myClassMethod.call();
</code></pre>

<p>An odd scenario I know but it works cleanly, I'm just not sure if this creates any memory or referencing issues?</p>

<p>Thanks</p>
