Deleting a window property in IE

后端 未结 4 1534
孤独总比滥情好
孤独总比滥情好 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 09:04

    I would do it this way:

        window[x] = undefined;
        try{
            delete window[x];
        }catch(e){}
    

提交回复
热议问题