Assuming the following in the global window scope:
var myvar = "initial value";
//some other code
myvar = "new value";
Is the old value destroyed from memory as soon as the new value is assigned? Of will it be Garbage Collected? My profiling tests suggest the memory is freed right away.
And same question when declared in a function scope.
var myfunct = function(){
var myvar = "initial value";
//some other code
myvar = "new value";
}
PS: No need to answer on the garbage collection in general. I already have an understanding how that works... I am only after the memory re-assignment aspect for this question. I know that global variables never get collected. But I am curious if the memory reassignment also get treated differently at the root.