Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript object remove

Tags:

javascript

Please excuse my question if it doesnt make much sense.

I am using javascript to create a dom element to do that i create an object ( obj ={}) and fill out the properties as i go, one of which is the dom element to be created. once the element is created and appended to the document i do not need the object to occupy any space in the memory so i was thinking i should remove it. how would i go about doing that? thank you

like image 713
salmane Avatar asked Jul 09 '26 05:07

salmane


2 Answers

The object's going to exist in memory as soon as it's in the DOM, and the obj property that holds it is really holding a reference to it, not a copy. So as far as I know, the memory required to keep the reference as a property of obj should be negligible. In which case I wouldn't worry about removing it at all.

like image 76
Karl B Avatar answered Jul 11 '26 21:07

Karl B


here is how:

my_var = null;

//or remove it
delete my_var;
like image 45
Sarfraz Avatar answered Jul 11 '26 20:07

Sarfraz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!