salmane
salmane

Reputation: 4849

javascript object remove

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

Upvotes: 3

Views: 8060

Answers (3)

user160820
user160820

Reputation: 15210

if you define you object as locale like

var obj ={}

it will be automatically undefined at the end of the function.

Upvotes: 0

Karl B
Karl B

Reputation: 1597

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.

Upvotes: 3

Sarfraz
Sarfraz

Reputation: 382696

here is how:

my_var = null;

//or remove it
delete my_var;

Upvotes: 3

Related Questions