I'm learning about closures and I want to know a bit about the garbage collector behavior. In the following code:
function valueMaker(name, value) {
var final = {};
final[name] = value;
final[double] = value*2;
return final;
}
first = valueMaker('first', 1);
When I call valueMaker
it creates a closure where I have the final
object, then, it returns the object.
My question is: The returned object count as a reference to the closure? or JavaScript is smart enough to know when I want to keep the closure alive?