Referencing global variables in local scopes

Posted by Jineesh on Stack Overflow See other posts from Stack Overflow or by Jineesh
Published on 2010-05-17T08:11:27Z Indexed on 2010/05/17 8:20 UTC
Read the original article Hit count: 276

Filed under:

Hello,

I would like to know memory leak in the below mentioned code. Does JavaScript do automatic garbage collection.

var aGlobalObject = SomeGlobalObject; 
function myFunction() {
   var localVar = aGlobalObject;
}

Do I have to clear the memory as given below.

var aGlobalObject = SomeGlobalObject; 
function myFunction() {
   var localVar = aGlobalObject;
   localVar = null;// or delete localVar
}

Thanks

© Stack Overflow or respective owner

Related posts about JavaScript