开发者

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 开发者_JS百科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


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.


here is how:

my_var = null;

//or remove it
delete my_var;


if you define you object as locale like

var obj ={}

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜