Is it necessary (and if not necessary, is it useful?) To “release” a variable before making it a value of an object of another type. For example:

... var d = new Date(); ... d=null; // освобождение переменной ... d=new Date(2011,9,23); 
  • 100% unnecessary <br> <small> PS: you are writing to cpp? xD </ small> - Zowie

1 answer 1

There is no need to delete variables, since automatic garbage collection is implemented in JavaScript (unused memory is freed automatically), although it is possible. For example,

 z = 0; delete z; 

or

 z = New Number() delete z; 

Whether there is a practical benefit, it is not known, perhaps it can be determined by running specific tests for memory usage.