var foo="text";
foo="another text";
console.log(foo); //=>"another text"
I know strings in javascript are immutable. So here var foo points a memory block with the value "text" . After second statement foo points another memory block with the value "another text".
Now what happens to the first value("text") ? will it exist in the memory until the garbage collector pass?