Take for example this code:
var test = (function(){
  var name = 'rar';
  return function foo(){
    console.log('test');
  };
}());
foo gets returned to test without any references to name in the inner scope. What happens to name? Is it destroyed? Or does it continue to exist and dangle with the returned function, but just can't be accessed? Would the first case be similar to doing the following, as if name was never part of the equation?:
var test = function foo(){
  console.log('test');
};
Here's another case:
var test2 = (function(){
  var name = 'rar';
  var age = '20';
  return function foo(){
    console.log(age);
  };
}());
age gets referenced by foo and will form a closure. However, name still isn't referenced by anything. What happens to name in this case? Is it destroyed? Or does it continue to exist and dangle with the returned function, but just can't be accessed?
 
    