Deleting a window property in IE

后端 未结 4 1535
孤独总比滥情好
孤独总比滥情好 2021-01-30 08:25

I can\'t find any information on this issue; why doesn\'t the following code work in IE?

window.x = 45;
delete window.x;
// or delete window[\'x\'];
4条回答
  •  既然无缘
    2021-01-30 08:58

    Does this help?

    window.x = 45;
    alert(window.x);
    window.x = null;
    

    I tried this in IE and window.x did have a value, which proves it can be set. Setting the value to null is your best bet for clearing it out.

提交回复
热议问题