Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript garbage collection when variable goes out of scope

Does JavaScript support garbage collection?

For example, if I use:

function sayHello (name){
    var myName = name;
    alert(myName);
}

do I need to use "delete" to delete the myName variable or I just ignore it?

like image 460
DNB5brims Avatar asked Dec 09 '22 18:12

DNB5brims


1 Answers

no.
delete is used to remove properties from objects, not for memory management.

like image 171
Kobi Avatar answered Mar 02 '23 15:03

Kobi