javascript 如果本机函数被删除 如何恢复

javascript if native function deleted How to recover

if javascript 本机函数为 alert

alert = null

如果我想使用alert如何恢复

可能不适用于所有浏览器

var x = document.createElement('iframe');
x.style.display = 'none';
document.body.appendChild(x);
window.alert = x.contentWindow.alert.bind(window);
// x.remove();
x.parentElement.removeChild(x); // because IE sux and should die

似乎适用于大多数地方(Firefox、Chrum、Edge 和 IE11)