If you don't assign temporary values to global variables, you should not even care about the problem you describe, since it's taken care for by a garbage collector. The principle is very simple: as soon as a value loses all pointers to it, it gets wiped out from the memory by a garbage collector.
For instance, in the following example the variables a and b exist only for as long as the function f executes:
var f = function () {
  var a = new A();
  var b = a;
}
Therefor since by the end of execution of f the value new A() loses all pointers to it, it gets wiped out by the GC.